News:

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

Main Menu

Display Additional Membergroups

Started by margarett, March 03, 2014, 11:02:35 AM

Previous topic - Next topic

remcoo

#80
Quote from: margarett on March 03, 2014, 11:02:35 AM


Hello Margaret,

I just installed your mod to my 2.0.9 SMF Forums, and this is what happens:





On both pages membergroups show double, any clue how to fix this? And is there maybe a way to show the actual images instead of the names on the profile section too?

OT: I'm looking for a way to make the username the "color in online list" from the primary membergroup, next to a post and on a profile, any mods for doing this? Fixed this part. :)

Thanks in advance. :)

margarett

Hi

I removed your other topic. No need to have the same question in multiple places, this is the place to be ;)

You have duplicate code, that's why you're having twice the content.
Check your Display.template.php. You should have this code twice:
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($modSettings['show_additional_groups_name']))
echo '
<li class="membergroup">', $temp['group'], '</li>';
echo '
<li class="membergroup">', $temp['stars_img'], '</li>';
}
}


Which means that duplicate code is spread throughout your files... You should check "Manual installation of Mods", but following backwards instructions and see if you find duplicate code. If so, remove the duplicate ;)
http://wiki.simplemachines.org/smf/Manual_installation_of_mods
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

remcoo

Quote from: margarett on May 13, 2015, 08:15:44 AM
Hi

I removed your other topic. No need to have the same question in multiple places, this is the place to be ;)

You have duplicate code, that's why you're having twice the content.
Check your Display.template.php. You should have this code twice:
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($modSettings['show_additional_groups_name']))
echo '
<li class="membergroup">', $temp['group'], '</li>';
echo '
<li class="membergroup">', $temp['stars_img'], '</li>';
}
}


Which means that duplicate code is spread throughout your files... You should check "Manual installation of Mods", but following backwards instructions and see if you find duplicate code. If so, remove the duplicate ;)
http://wiki.simplemachines.org/smf/Manual_installation_of_mods

Alright thanks a lot!

Is there any way you know of to add the membergroup icons to a profile page though? Instead of the membergroup names?

margarett

Not sure, I'd have to dig the code through the code again :P
I can try to check it later but now I'm terribly busy, sorry :(
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

remcoo

Quote from: margarett on May 13, 2015, 09:10:52 AM
Not sure, I'd have to dig the code through the code again :P
I can try to check it later but now I'm terribly busy, sorry :(

Alright man, thanks anyway! Lmk if you ever have the time to do so! :)

dominik523

Additional member groups aren't displayed on this theme:
http://custom.simplemachines.org/themes/index.php?lemma=2833
I just have primary group displayed.


420Connect.co.uk

Quote from: remcoo on May 13, 2015, 08:36:25 AM
Quote from: margarett on May 13, 2015, 08:15:44 AM
Hi

I removed your other topic. No need to have the same question in multiple places, this is the place to be ;)

You have duplicate code, that's why you're having twice the content.
Check your Display.template.php. You should have this code twice:
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($modSettings['show_additional_groups_name']))
echo '
<li class="membergroup">', $temp['group'], '</li>';
echo '
<li class="membergroup">', $temp['stars_img'], '</li>';
}
}


Which means that duplicate code is spread throughout your files... You should check "Manual installation of Mods", but following backwards instructions and see if you find duplicate code. If so, remove the duplicate ;)
http://wiki.simplemachines.org/smf/Manual_installation_of_mods

Alright thanks a lot!

Is there any way you know of to add the membergroup icons to a profile page though? Instead of the membergroup names?



To add the additional groups in your profile page, use the code:

if (!empty($context['member']['additional_groups_full'])) {
foreach($context['member']['additional_groups_full'] as $temp) {
if (!empty($modSettings['show_additional_groups_name']))
echo '
<li class="membergroup">', $temp['group'], '</li>';
echo '
<li class="membergroup">', $temp['stars_img'], '</li>';
}
}


:) enjoy




Quote from: dominik523 on May 17, 2015, 04:17:02 AM
Additional member groups aren't displayed on this theme:
http://custom.simplemachines.org/themes/index.php?lemma=2833
I just have primary group displayed.


Confirms this and would also appreciate a fix as I'm preparing to update to the same theme soon.

Many thanks Bruno!
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

Rayvon

I just installed the Additional groups today and I'm getting an undefined index error in my Load.php file



Line 1341        'additional_groups' => $profile['additional_groups'],

I use UTF-8 as my language, I noticed the editor doesn't touch the UTF8 english file so I replicated the changes in it (so the modification settings per your installer are applied currently to both modifications.english-utf8.php and in the modifications.english.php file your installer automatically does) .. This didn't seem to fix it, anytime anyone loads up a page it displays an error. However, when I look at the profiles in the forum, they appear to be displaying just fine (I do see all the displayed groups for each person) ..

Should I be concerned about this error on line 1341 of Load.php?

margarett

Howdy.

I'm now checking Redsy as I will also be using it shortly. It does show the additional membergroups but in a very weird way :P (see attachment)

@rayvon: you probably skipped a modification error in Load.php. That line is replaced with:
'additional_groups_full' => $profile['additional_groups_full'],
'additional_groups_list' => $profile['additional_groups_list'],
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Rayvon

Quote from: margarett on May 18, 2015, 01:27:07 PM
@rayvon: you probably skipped a modification error in Load.php. That line is replaced with:
'additional_groups_full' => $profile['additional_groups_full'],
'additional_groups_list' => $profile['additional_groups_list'],


I replaced it with that code, and it's giving me a new error now.

8: Undefined index: additional_groupsApply Filter: Only show the errors from this file File: /home/newsi908/public_html/forums/Themes/default/Display.template.php
Line: 587


Line 587 of Display.template.php
if ($context['can_ban'] && empty($message['member']['is_guest']) && $message['member']['group_id'] != 1 && !in_array(1, explode(',', $message['member']['additional_groups'])))

margarett

That line doesn't exist in default SMF :o Probably a MOD that allows ban from Display?
Anyway, just replace
!in_array(1, explode(',', $message['member']['additional_groups'])))
with
!in_array(1, $message['member']['additional_groups_list']))
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Rayvon

Quote from: margarett on May 18, 2015, 02:25:52 PM
That line doesn't exist in default SMF :o Probably a MOD that allows ban from Display?
Anyway, just replace
!in_array(1, explode(',', $message['member']['additional_groups'])))
with
!in_array(1, $message['member']['additional_groups_list']))

Ban in Post, yes I have that installed [http://custom.simplemachines.org/mods/index.php?mod=1876] ..

Trying the $message fix now .. Seems to work so far, no errors popping up immediately when I refresh a thread anymore ... Thank you!! :)

margarett

About Redsy.

The MOD probably put this in Display.template.php. If so, remove it:
//Show additional groups, if the user has some attributed
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($modSettings['show_additional_groups_name']))
echo '
<li class="membergroup">', $temp['group'], '</li>';
echo '
<li class="membergroup">', $temp['stars_img'], '</li>';
}
}

Redsy doesn't show group names, just "stars". So we'll do the same. Find:
// Show the stars if they are not in a group.
echo '
<li class="stars">', $message['member']['group_stars'], '</li>';

Add after
//Show additional groups, if the user has some attributed
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($temp['stars_img']))
echo '
<li class="stars">', $temp['stars_img'], '</li>';
}
}


Do note: this prevents the MOD from being automagically removed from this theme. But because this is such great MOD, you will not want to uninstall it ;D ;D ;D
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

420Connect.co.uk

Thanks for the fix Brun'  ;)

m'sure it will come in handy when I get everything set up!
www.420Connect.co.uk ~ A Social Network For The #CannabisCommunity ~ Come say "High" ;)

dominik523

Quote from: margarett on May 18, 2015, 02:36:28 PM
About Redsy.

The MOD probably put this in Display.template.php. If so, remove it:
//Show additional groups, if the user has some attributed
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($modSettings['show_additional_groups_name']))
echo '
<li class="membergroup">', $temp['group'], '</li>';
echo '
<li class="membergroup">', $temp['stars_img'], '</li>';
}
}

Redsy doesn't show group names, just "stars". So we'll do the same. Find:
// Show the stars if they are not in a group.
echo '
<li class="stars">', $message['member']['group_stars'], '</li>';

Add after
//Show additional groups, if the user has some attributed
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($temp['stars_img']))
echo '
<li class="stars">', $temp['stars_img'], '</li>';
}
}


Do note: this prevents the MOD from being automagically removed from this theme. But because this is such great MOD, you will not want to uninstall it ;D ;D ;D

Thank you so much Bruno for the help. I haven't find the first part. That is okay, right?
And for the second, stars, part, here's my code:
// Show the stars if they are not in a group.
echo '
<li class="stars">', $message['member']['group_stars'], '</li>';

//Show additional groups, if the user has some attributed
if (!empty($message['member']['additional_groups_full'])) {
foreach($message['member']['additional_groups_full'] as $temp) {
if (!empty($temp['stars_img']))
echo '
<li class="stars">', $temp['stars_img'], '</li>';
}
}

Did I write it correctly? Sorry I haven't worked with any web scripting so this all is really new to me.
Of course we won't uninstall it, it's awesome :)
Oh, last thing. Does SMF have any limit on number of assigned membergroups to a single member?

margarett

Indentation is quite messed but the content seems to be there.
(I'm an indentation freak :P )

QuoteOh, last thing. Does SMF have any limit on number of assigned membergroups to a single member?
Code-wise, not. But the database field where the additional membergroups is stored is a VARCHAR 255, where the membergroup IDs are stored comma-separated. With an average of 3 digits per group (2 digits for the ID and one for the comma), it should store max 85 groups.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dominik523

Okay I did it. Everything works. Thank you so much Bruno! You're the best :D

Shambles

Bruno (aka margarett) for President. All say "Aye"

dominik523


Gluz

Umm, take notes on this... I'm installing a forum with Reseller that is somewhat similar to Redsy, so this will save some work ;D

Quote from: margarett on May 18, 2015, 05:12:07 PM
(I'm an indentation freak :P )

Python make me an indentation freak too, I edit the mods I install just to keep the right indentation on the edits and files. I edit them properly, from package_info.xml and install.xml(or what they use).

Advertisement: