News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Group prefix postfix text

Started by ketwaroo, April 06, 2007, 02:32:05 PM

Previous topic - Next topic

ketwaroo

Link to Mod

edit -- mod was written under SMF 1.1.1. It has been tested and found to work under SMF 1.1.1 to 1.1.5

!! Warnings !!
- this mod is know to conflict with the Member colour Link mod.
- Uninstall previous version before upgrading
- As usual. Use At Your Own Risk. No Warranties. Don't Run With Scissors, etc.


And now, back to the read me.

Behind the slightly barbaric name, is a neat little trick for those of you
upgrading from free sevice like invisionfree to better free service like SMF,
you might be missing the Group name prefix and posfix feature.

This mod does 2 things.
1. Allow you to add a prefix and/or a postfix text to to all user links
   belonging to a certain membergroup.
   The results are visible on display names in the posts and personal messages.
   But not the online users list.(as of 1.3, also works on post based groups)
  
2. Make the display name the same colour as their assigned membergroups.
   whether you specify a prefix/postfix or not, the colour will be changed.

This mod will add 2 new text-boxes to the add/edit membergroup menu.
Unless your theme modifies the ManageMembergroups.template.php file, it should
work on all themes once installed.

example: you have a user with name Bruno of the membergroup monty.
you go in your admin panel, edit the Monty group.
In the Prefix box you add "King "
and in the Postfix box, you add " the Questionable"

so in the posts and personal messages, it becomes "King Bruno the Questionable"

now if there was also a member, we shall call Martin Luther in the Monty group,
He would be displayed as "King Martin Luther the Questionable".

Now the main purpose of this mod is not to add just plain text. You can add HTML
too. this example to give you 2x size fonts:

prefix: <span style="font-size:2em">
postfix: </span>

You can add pretty much what you want in HTML. For that reason, be cautious not
to insert code that will break your display. If you are using this mod, you
are most likely admins. Act like admins.

note that bbcode will not be parsed. just displayed as plain text.

note also that colour style attributes, if defined inline from within the postfix,
will override the colour field of that member group. Colour defined in classes
in the style.css will be overridden by group colour.

it's prefix style colour > menbergroup colours > css style colour

Version History:

New in 1.1 - added some checks for empty/undefined prefix and postfix strings.

fixed in 1.2 - typo which caused the prefix to be displayed in both textboxes in
the manage membergroup template

New in 1.3 - Added a hack by Alpha_Vector to include post based groups.
No longer saves empty prefix or postfix to modsettings. Already too much
junk in that table...
Regular Groups override post Count Based Menbergroups.

Fixed in 1.31 - a horrendous typo.

Fixed in 1.4 - Everything.

Fixed in 1.41 - some colouring issue for post count based groups. Pointed out by mattz83.

pongsak

There're 2 problems that i found.
I've use 1.1.2 with dilber theme and many mods. including member color link.

1. the prefix and postfix value 're not be remembered. It's disappeared after reloaded.
2. how can i modify then code below in the load.php (i've tried it myself but the mod not word , may be my mistake)


'link' => '<a href="' . $scripturl . '?action=profile;u=' . $profile['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $profile['realName'] . '">' . (!empty($modSettings['MemberColorLink']) ? ( !empty($profile['member_group_color']) || !empty($profile['post_group_color']) ? '<span style="color:'. ( !empty($profile['member_group_color']) ? $profile['member_group_color'] : $profile['post_group_color'] ) .';">' : '' ) : '' ) . $profile['realName'] . (!empty($modSettings['MemberColorLink']) && (!empty($profile['member_group_color']) || !empty($profile['post_group_color'])) ? '</span>' : '' ).'</a>',
'email' => &$profile['emailAddress'],
smf 1.1.2 with dilbermc themes.
> 50 mods installed.

ketwaroo

Sorry for the late reply. I don't usually visit the smf support forums unless there is a problem I need to solve (which doesn't happen very often).

The mod I wrote is a quick and dirty one. It uses the modsetting array to store the prefix and postfixes instead of adding extra attributes to the membergroup table. I fixed the disappearing fields with version 1.2 of the mod. If you have the older 1.1 version, uninstall it and reinstall the 1.2 version. I didn't add upgrade instructions.

note that if the mod gives an error message when you install it, you shouldn't install it until you are sure what is the cause of error.

well from the line you pasted it seems that is a conflict with the member color link mod. I think.

It seems like an awfully complicated line too. and somehow, I don't think you can use the (condition)?<if true instruction>:<else instruction> when concatenating strings with the "." operator. I had to add 2 new variables to hold the evaluated prefix and postfix so that i could add them to the string.


$pre_title
=isset($modSettings['prefix_group'.$profile['ID_GROUP']])?$modSettings['prefix_group'.$profile['ID_GROUP']]:'';
$post_title=isset($modSettings['postfix_group'.$profile['ID_GROUP']])?$modSettings['postfix_group'.$profile['ID_GROUP']]:'';


added before the $memberContext[$user] array in Load.php. look for the "what a monstrous array" comment.

and then the 'link' data becomes:


'link' => '<a href="' $scripturl '?action=profile;u=' $profile['ID_MEMBER'] . '" title="' $txt[92] . ' ' $profile['realName'] . '" style="color:'.$profile['member_group_color'].';">'$pre_title $profile['realName'] . $post_title '</a>',


may not be recommended SMF coding standards but its much simpler
Sorry if I can't help much.

the mod is working fine on my forum ever since i wrote it. check it here: www.nbforums.net/forum [nofollow]
the admins have huge red smallcaps names. it scares the newbs.

Alpha_Vector

#3
Really good mod, helps people like me that before were using an IPB like software that has this feature and recently migrated the board, wanting to preserve all they had in their old installation.

I just want to point something, it doesn't work with post based groups because SMF always makes a distinction between post groups and the other ones.

$profile['ID_GROUP'] evaluates to zero if the member only is inside a post based group.
$profile['ID_POST_GROUP'] contains the info of the posters post based group.

Here is my fix, which adds more to the hackish nature of the mod as it is all my skill level allows me to do:
Below

$pre_title
=isset($modSettings['prefix_group'.$profile['ID_GROUP']])?$modSettings['prefix_group'.$profile['ID_GROUP']]:'';
$post_title=isset($modSettings['postfix_group'.$profile['ID_GROUP']])?$modSettings['postfix_group'.$profile['ID_GROUP']]:'';


Add

$pre_title
=(empty($pre_title) && isset($modSettings['prefix_group'.$profile['ID_POST_GROUP']])) ?$modSettings['prefix_group'.$profile['ID_POST_GROUP']]: $pre_title;
$post_title=(empty($post_title) && isset($modSettings['postfix_group'.$profile['ID_POST_GROUP']])) ?$modSettings['postfix_group'.$profile['ID_POST_GROUP']]: $post_title;
	




Note: Here prefixes and postfixes declared on non post based groups take precedence over post ones, which probably is how you want it to be.

_Anthony_

Can someone udate this for smf 2.0?

ketwaroo

sorry for not replying. the mod is the usual "use at your own risk" sort. But I can still fix things if they need fixing.

and thanks Alpha_Vector. looks fine to me. except I'll use strlen() instead of empty(). that way you can add the string "0" to the pre/postfix (extreme rare case I know, but what the heck).

I'll add your hack to the mod and re upload it.

and I'm not currently using SMF 2.0. waiting for a more stable version. so anybody else is free to have a go at it.


Noanme

I have a problem: I can't acces to membergroups because the mod! And you have deleted the old version too :( Can you fix it?

I tried to fix it myself in php, but there are more, and more errors! :( Please!

ketwaroo

#8
wut?

ahh ******e!

the one I'm using is working fine but it seems I uploaded the wrong edit.

for starters, Don't Panic

look for

	
	
if!empty(
$ppfix))
	
	
	
updateSettings($ppfix);


and replace with


	
	
if (!empty(
$ppfix))
	
	
	
updateSettings($ppfix);


there's a missing opening "(".

I'm reuploading it now.

you can still uninstall it from the package manager if you haven't modified too much php.

If you have modified too much php, then you're in luck because SMF makes an automatic backup of all the files modified. in the  <smf install dir>/Packages/backups folder. It's usually in tar.gz format. the name should look like <some date>_before_Group_PrePosfix.tar.gz. You just have to extract and replace.

otherwise it works fine up to 1.1.5.

Edit - file fixed.

Noanme

Thank you very much the fast update  ;) And the help :)

(now I can't upload packages, because my server is in Upgrade, so i must wait, to upload this mod) :(

Dragonsbrethren

I just replaced Member Color Link with this mod, so far it's been working great, it doesn't color as many fields but it also doesn't cause an error every time someone searches my forum or remove regular members' names from their birthdays on the calendar. Anyway, I am getting two minors error every time I modify a membergroup:

8: Undefined index: postfix_group1
File: /Sources/ManageMembergroups.php
Line: 530


8: Undefined index: prefix_group1
File: /Sources/ManageMembergroups.php
Line: 529


Any idea how to fix this?

ketwaroo

Odd. I didn't notice that before.

Seems the settings are saved to database but the $modSettings array isn't updated.

but this is a one time error (well, more like a minor warning) that happens only in the admin contol panel. it won't occur again next time you edit the same membergroup.

anyway. fixed.

and fixed a lot of other things on the way. should be final for the SMF 1.1.x line.


mattz83

The problem I am having with this mod is a conflict with the member color link mod as well. It causes the mod not to color some names inside threads, yet it will not color them itself. Once you've clicked inside the actual topic, no names are colored for members of post count based groups. I tried adding the hack above, but it didn't do anything. It's like the mod isn't recognizing that it should color names of posters in post count ranked groups...

Any suggestions?

ketwaroo

I think it's already stated in the read me. It doesn't work with member color link... Both mods modify the same lines. You use either one or the other...

You had been warned. It's use at your own risk. You used with a known risk. So I can't help you.

mattz83

Quote from: ketwaroo on July 27, 2008, 06:36:26 PM
I think it's already stated in the read me. It doesn't work with member color link... Both mods modify the same lines. You use either one or the other...

You had been warned. It's use at your own risk. You used with a known risk. So I can't help you.

You don't quite understand. The reason no names are colored inside the threads is because of the conflict. Like you said, they modify the same line. If you apply the code from your mod instead of the color link mod then it should color the links inside the threads instead of the color link mod coloring them.

So the question is, why doesn't your mod color the names of posters inside the thread whose groups are based on post count? Even with the color link mod uninstalled on the main forum AND on the test forum, the result is the same. Your mod does not color names of members in post count based groups.

I am asking for help with THAT issue, NOT the conflicting lines of code between the two mods.  If the line yours modifies causes the color link mod to not color the names inside the threads, but your mod does color them... for what reason, then, should we not be able to use both? Of course that is supposing your mod correctly colors the names of posters inside threads, which it does not.

ketwaroo

damn, took a few minutes to re-read everything to get what you meant.

It's an issue with SMF making a distinction between post based groups and regular groups as Alpha_Vector mentioned.

One easy work around is to used inline styles in the prefix/postfix.

something like <span style="color:#something;"></span>

I'll be fixing and reuploading the mod either ways.

mattz83

Quote from: ketwaroo on July 28, 2008, 03:02:12 PM
damn, took a few minutes to re-read everything to get what you meant.

It's an issue with SMF making a distinction between post based groups and regular groups as Alpha_Vector mentioned.

One easy work around is to used inline styles in the prefix/postfix.

something like <span style="color:#something;"></span>

I'll be fixing and reuploading the mod either ways.

Thank you very much for the update to your mod. After tinkering with load.php a little bit and adjusting some things to make the mod install properly, I am now successfully using both the color link mod and this one.

You're awesome, thanks!

Deadfire

#17
Is it possible that this mod also has the preefix on the board view and not just in the topic and member list?

bfeo



Advertisement: