JD
Full Member
Posts: 771
inherit
180643
0
Sept 27, 2024 15:01:41 GMT -8
JD
771
June 2012
obsidian92
|
Post by JD on Jul 3, 2019 1:38:58 GMT -8
URL: aeipathy.forums.net/Okay I've tried fiddling with the code that I know on this one but I'm hitting a dead end. I assume this can be done quite easily and that I'm just struggling with the right syntax for the code. That being said, perhaps someone more experienced will know... I am trying to have a list of icons appear in a member profile based on the groups they are in. Ergo, if I have 10 groups and this particular member is in group 2, 7 and 9, the icons for groups 2, 7 and 9 will show on their profile. I've tried doing this via the stars system, just replacing those but there aren't enough stars for the number of groups I need. Ergo, I'm falling back on good old manual. But I can't seem to get the foreach to work., it just shows me the first user group - ergo the one that is set to "show" for the account. Is there any way I can override this in the profile layouts code? At the moment I have something like this: {if $[user.group]} {foreach $[user.group]} {if $[user.group.name] == "House: Antonis"}<img src="https://storage.forums.net/7040057/images/ZUbyiujhBqAFMejswJzc.png">{/if} {if $[user.group.name] == "House: Marikas"}<img src="https://storage.forums.net/7040057/images/CxtxsaUjtVjduLAgzydu.png">{/if} {if $[user.group.name] == "House: Stravos"}<img src="https://storage.forums.net/7040057/images/shmCfdkQAYzNezxEdglQ.png">{/if} {/foreach} {/if} With the foreach, I get nothing. Without it, I just get the Antonis icon (the first one).
|
|
#eb7100
33409
0
1
Nov 13, 2024 16:56:46 GMT -8
Brian
48,130
November 2004
smashmaster3
|
Post by Brian on Jul 3, 2019 10:20:24 GMT -8
{foreach} can only loop through variables that contain an array of data.
$[user.group] does not contain data that can be looped through. It's made to show just the display group specified in your profile settings and that's it. For that reason it's not possible to display every group you're a part of as that's the only variable that outputs group names.
The variables that {foreach} does work on usually contain all of the following subvariables:
- even - index - iteration - lastIndex - odd
|
|
JD
Full Member
Posts: 771
inherit
180643
0
Sept 27, 2024 15:01:41 GMT -8
JD
771
June 2012
obsidian92
|
Post by JD on Jul 3, 2019 10:24:35 GMT -8
{foreach} can only loop through variables that contain an array of data. $[user.group] does not contain data that can be looped through. It's made to show just the display group specified in your profile settings and that's it. For that reason it's not possible to display every group you're a part of as that's the only variable that outputs group names. The variables that {foreach} does work on usually contain all of the following subvariables: - even - index - iteration - lastIndex - odd Thanks for letting me know Brian! I'll keep doing what I'm doing with the custom profile fields then
|
|