News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Alternate Text Mod

Started by B Patterson, January 04, 2007, 07:19:48 PM

Previous topic - Next topic

B Patterson

Link to Mod
Rate this Mod

This modification will allow you to change the alternate text for each membergroup.

What that means is that the membergroup stars, when hovered over, will give a tool-tip of your custom alternate text.  Currently, the default text in SMF is "*"; however, with this mod, you can change any membergroup's alternate text to what you want.

COMPATABILITY:
Multiple Badges (AKA Stars):
QuoteThis is an easy two step fix.


  • Open Sources/Load.php and at the end of the file you should see something that looks like this:
    function getgroupstars($id$stars)
    {
      global 
    $context$db_prefix$settings;
      
    $ret '';
      
    $allstars = array($stars);
  • On the line that says "global $context, $db_prefix, $settings;" make it look like this:
    global $context$db_prefix$settings$profile; (i.e.: Add ", $profile" between the semi-colon and the last letter of "settings").
  • Look through the function until you find this:
     $starstrings[] = str_repeat('<img src="' str_replace('$language'$context['user']['language'], isset($star[1]) ? $settings['images_url'] . '/' $star[1] : '') . '" alt="*"
  • Replace that with this:
     $starstrings[] = str_repeat('<img src="' str_replace('$language'$context['user']['language'], isset($star[1]) ? $settings['images_url'] . '/' $star[1] : '') . '" alt="' $profile['altText'] . '"

littleone

I installed it and got this error:

Parse error: syntax error, unexpected T_STRING in /home/xxxxxxxx/public_html/forum/Sources/Load.php on line 858

Here is what line 857 and 858 looks like:
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.stars, mg.stars) AS stars" . (!empty($modSettings['titlesEnable']) ? ',
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.altText, mg.altText) AS altText,

littleone

I am also getting this to flood my logs:

8: Undefined variable: user_profile
File: /home/xxxxxxxxx/public_html/forum/Sources/Load.php
Line: 2301

Code for that line:
     $starstrings[] = str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($star[1]) ? $settings['images_url'] . '/' . $star[1] : '') . '" alt="' . $profile['altText'] . '" border="0" />', empty($star[0]) ? 0 : $star[0]);
 

B Patterson

#3
What version of SMF are you using?  If it's 1.1.2, it won't work as I've only supported it to 1.1.1.

Also, line 2301 is where the PHP parser fails to continue, you need to show the previous few lines as well.

littleone

well thats my problem I was using 1.1.2.  I figured it would work since there wasnt a big difference.  Ill wait for the upgrade :P  Thanks

B Patterson

Well, unfortunately it works for me with a brand new install of 1.1.2.... what other mods do you have installed, and when and where are you getting the errors?

littleone

I think the main mod 2 mods it could be conflicting with is the Multiple Badges aka Stars mod and then AwwwLilMaggie's Show stars in profile mod.

IDK where the errors were coming from but within 15 minutes I had a couple hundred pages of the errors.  I think it was occuring for each image (so 5 stars would make 5 errors) for each time a set of stars was being loaded on each page.

B Patterson

Well I don't use a variable named $user_profile in my mod.  It's not anywhere in my modification file (even in the stuff to search for).  So that error about the "Undefined variable: user_profile" isn't mine. :(  Sorry.

Lines 857 and 858 (though it's 868 and 869 in my code) should be
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.stars, mg.stars) AS stars,
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.altText, mg.altText) as altText,


But that's from a clean install.....  You may have to manually look at what the other mods are putting into the SQL, then manually correct the Load.php file.

littleone

oh sorry.  I changed it from profile to user profile to see if that would take away the error so thats the one i posted it but it did the same thing.

B Patterson

Well if you have no $profile variable.... then there's something wrong with your SMF install as that holds all the user profile stuff.....

I can't reproduce this on a clean install.   I'll try working on it a little this week to see what I can come up with.

B Patterson

Profile Stars by AwwLilMaggie - Can't be it.  It doesn't even touch the file "Load.php"
Multiple Stars by Thantos - Seems that I found the issue.

Issue is, it's not gonna work.  Unless SMF has a way for mods to use Conditionals (something like if([mod_X_installed]) { execute_XML } else { execute_XML_2 } ) I can't make a compatible mod.  Unfortunately, you'll have to do it by hand, but I know how to fix it.  See my first post for the answer ;)


B Patterson

As for your SQL error.... look at your code:
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.stars, mg.stars) AS stars" . (!empty($modSettings['titlesEnable']) ? ',
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.altText, mg.altText) AS altText,


It should look like this:
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.stars, mg.stars) AS stars,
IF(mem.ID_GROUP = 0 OR mg.stars = '', pg.altText, mg.altText) AS altText" . (!empty($modSettings['titlesEnable']) ? ',
mem.usertitle' : '');

Sandwich

Anyway to easily modify this so that along with the ALT text, you can define a link for each membergroup's stars/badges to link to?

B Patterson

I don't see why not.  Let me work on it, and I'll update the mod.

Sandwich

Thanks! If it makes any difference, I'm looking to use it along with the Multiple Badges/Stars mod.

JungleBunny

Thanks, works great with 1.1.2 :D :D :D

WebWorm

Anybody have any luck with installing this on 1.1.3? All I get when I try is:

QuoteInstallations actions for "Alternate Text for Member Group Images":
The package you are trying to download or install is either corrupt or not compatible with this version of SMF.

If there's a manual fix for this, would love to try it out.

B Patterson

Should work with 1.1.3.  I haven't tried it yet.  Sounds like your download isn't working right because the package should work, at least to say that it can't be installed.  Where are you getting the package from?

WebWorm

bpat, I'm downloading it directly from SMF to my HD, and then uploading it to the package manager.

I'll give it a whiff again, and see if maybe my version got corrupted in the process.

WebWorm

Nargh, still no luck with 1.1.3 - I've also already done the manual modifications for Multiple Badges (AKA Stars), I don't know if that makes a difference. :(

I want this mod so badly to work!

Advertisement: