irontongue
New Member
Headed to the gym.
Posts: 82
inherit
257751
0
Apr 21, 2021 3:35:54 GMT -8
irontongue
Headed to the gym.
82
February 2019
irontongue
|
Post by irontongue on Apr 15, 2019 17:27:09 GMT -8
Okay, here is what I have for the script:
<script> var css = "<style>";
if($[current_user.is_staff]) { css += ".site_admin{ display: block!important; }"; }
if($[current_user.group.id] == 4) { css += ".clan_member{ display: block!important; }"; } css += "</style>";
$("head").append(css); </script> The links I did not change.
Works fine for the first link. (Staff)
The second link for the group doesn't show at all.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Apr 15, 2019 21:48:04 GMT -8
irontongue, There is a catch with comparing a user's group ID (or group name). In order for the template variable to return a true to that comparison, the user must have that group as their currently displayed group in their profile ( Profile > Edit Profile > Settings (tab) > Display Group (option)). For example, let's say I belong to 2 groups: - Group A (group ID is 1) - Group B (group ID is 2) If the if statement was written as: if($[current_user.group.id] == 1)
and if my current displayed group was Group B (group ID of 2), then that if statement will return a false because Group A (group ID of 1) is not my currently displayed group. That template variable only sees the user's current display group - it does not see all of the groups that user is in. There's a couple of options available here: (1) Have the user(s) in question edit their profile and set their display group to that of the one being checked; OR (2) You can try ( not tested) replacing these lines: if($[current_user.group.id] == 4) { css += ".clan_member{ display: block!important; }"; }
with this (comments are highlighted and can be left out): Again, I have NOT tested that. If I typed that in correctly, it should check to see if the user belongs to a group that has ID of 4, regardless of what group they have displayed. DISCLAIMER: You may want to wait until a more experienced coder takes a look at this to see if I got it right BEFORE you try to implement it.
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Apr 16, 2019 10:02:39 GMT -8
Okay, here is what I have for the script:
<script> var css = "<style>";
if($[current_user.is_staff]) { css += ".site_admin{ display: block!important; }"; }
if($[current_user.group.id] == 4) { css += ".clan_member{ display: block!important; }"; } css += "</style>";
$("head").append(css); </script> The links I did not change.
Works fine for the first link. (Staff) The second link for the group doesn't show at all.
irontongue, There is a catch with comparing a user's group ID (or group name). In order for the template variable to return a true to that comparison, the user must have that group as their currently displayed group in their profile ( Profile > Edit Profile > Settings (tab) > Display Group (option)). For example, let's say I belong to 2 groups: - Group A (group ID is 1) - Group B (group ID is 2) If the if statement was written as: if($[current_user.group.id] == 1)
and if my current displayed group was Group B (group ID of 2), then that if statement will return a false because Group A (group ID of 1) is not my currently displayed group. That template variable only sees the user's current display group - it does not see all of the groups that user is in. There's a couple of options available here: (1) Have the user(s) in question edit their profile and set their display group to that of the one being checked; OR (2) You can try ( not tested) replacing these lines: if($[current_user.group.id] == 4) { css += ".clan_member{ display: block!important; }"; }
with this (comments are highlighted and can be left out): Again, I have NOT tested that. If I typed that in correctly, it should check to see if the user belongs to a group that has ID of 4, regardless of what group they have displayed. DISCLAIMER: You may want to wait until a more experienced coder takes a look at this to see if I got it right BEFORE you try to implement it. Lynx is correct, sorry about that.. And the solution above should work, but it can be shortened somewhat.. Just change... if($[current_user.group.id] == 4) to if($.inArray(4,pb.data('user').group_ids) != -1) With the red number being the group ID.
|
|
irontongue
New Member
Headed to the gym.
Posts: 82
inherit
257751
0
Apr 21, 2021 3:35:54 GMT -8
irontongue
Headed to the gym.
82
February 2019
irontongue
|
Post by irontongue on Apr 17, 2019 7:49:08 GMT -8
Okay, for some reason this isn't working for me.
I give up.
Thanks anyway.
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Apr 17, 2019 9:15:40 GMT -8
Okay, for some reason this isn't working for me. I give up. Thanks anyway. If you post your entire template (inside of code tags), someone should be able to see what the issue is. Thanks, Todge! I was going to do that, but couldn't remember the syntax for it, so I had to go the long route.
|
|
irontongue
New Member
Headed to the gym.
Posts: 82
inherit
257751
0
Apr 21, 2021 3:35:54 GMT -8
irontongue
Headed to the gym.
82
February 2019
irontongue
|
Post by irontongue on Apr 17, 2019 10:29:39 GMT -8
Okay, for some reason this isn't working for me. I give up. Thanks anyway. If you post your entire template (inside of code tags), someone should be able to see what the issue is. Thanks, Todge ! I was going to do that, but couldn't remember the syntax for it, so I had to go the long route.
<!DOCTYPE HTML> $[tag.html.open] <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>$[title] | $[forum.name]</title> <script type="text/javascript" language=JavaScript src="http://www.evil-incarnate.com/form/browserdetection.js"> </script> $[head] <!-- <div id="navigation-menu" class="ui-helper-clearfix"> <ul role="navigation"> {foreach $[navigation.menu]} <li> <a{if $[navigation.menu.active]} class="state-active"{/if} href="$[navigation.menu.href]"{if $[navigation.menu.accesskey]} accesskey="$[navigation.menu.accesskey]"{/if}> $[navigation.menu.name] {if $[navigation.menu.notification.total]} <div class="tip-holder" onclick="window.location='$[navigation.menu.notification.href]'; return false;"> <div class="tip-number">$[navigation.menu.notification.total]</div> <span class="tip"></span> </div> {/if} </a> </li> {/foreach} </ul> <p id="welcome"> {if $[current_user.is_member]} $[current_user.name] (<a href="$[logout_link.href]">signout</a>) - <a href="/conversations/inbox"><b>Inbox:</b></a> <font color="#c5bf9c">$[current_user.messages.inbox]</font> | New: <font color="#c5bf9c"><u>$[current_user.messages.new]</u></font> {else} Welcome Guest to $[forum.name]. $[login_link.] or $[register_link.] {/if} </p> </div> --> <style type='text/css'>div.peek-a-boo { background : transparent url('https://www.evil-incarnate.com/images/peek_smiley.gif') no-repeat scroll right bottom; bottom : 0; width : 100px; height : 100px; position : fixed; right : 0; } </style> </head> <body><div class='peek-a-boo'></div>
<script> var css = "<style>";
if($[current_user.is_staff]) { css += ".site_admin{ display: block!important; }"; }
if($.inArray(4,pb.data('user').group_ids) != -1) { css += ".clan_member{ display: block!important; }"; } css += "</style>";
$("head").append(css); </script> {if $[maintenance_mode]} <div class="maintenance-header"> {if $[can.disable_maintenance]}<p>Finished with maintenance? $[disable_maintenance_link].</p>{/if} </div> {/if} <div id="wrapper"> <header> <div id="banner-container" role="banner"> <h2 id="banner"> $[forum.title] </h2> </div> <a id="navigation-skip" href="#content" accesskey="s" class="aria-hidden" title="Skip Navigation">Skip Navigation</a> <a href="#" accesskey="d" title="Open Menu" onclick="proboards.hotkeys.activate(Keys.d); return false;"></a> </header> $[participated_threads_link]
<div id="navigation-tree"> $[navigation.tree] </div> $[header] <div id="content" role="main"> {if $[notice]} <div class="container"> <div class="title-bar"><h2>$[notice.title]</h2></div> <div class="content pad-all cap-bottom"> $[notice.message] </div> </div> {/if} $[content] $[shoutbox] </div>
$[footer] <!--- BEGIN CUSTOM EVIL FOOTER --->
<table align="center" cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td align="center" valign="top"><div align="center"><div class="container" id="Evil_Footer" style="margin-bottom: 0px;"> <div class="title-bar"> </div> <div class="content pad-all cap-bottom"> <div> <div align='center'>Theme by <a href="http://evil-incarnate.freeforums.net/user/1">Native</a> @ <a href="http://evil-incarnate.freeforums.net/">Evil-Incarnate</a> <br><br>You are visitor # <a href="http://www.hitwebcounter.com" target="_blank"> <img src="http://hitwebcounter.com/counter/counter.php?page=7036917&style=0038&nbdigits=9&type=page&initCount=7277100" title="http://www.hitwebcounter.com/htmltutorial.php" Alt="http://www.hitwebcounter.com/htmltutorial.php" border="0" > </a><br><br><script language="JavaScript"> <!-- //using browserdetection.js if(self.browserName) document.write('' +'Browser name = '+browserName+'<br>' +'Full version = '+fullVersion+'<br>' +'Major version = '+majorVersion+'<br>' +'navigator.appName = '+navigator.appName+'<br>' +'navigator.userAgent = '+navigator.userAgent+'<br>' )
</script> <script type="text/javascript"> var userip; </script> <script type="text/javascript" src="https://l2.io/ip.js?var=userip"></script> <script type="text/javascript"> document.write("Your IP is :", userip); </script></div> </div> </div></div></td> </tr> </table>
<!--- END CUSTOM EVIL FOOTER ---> {if $[is_mobile_browser]} <br /><p class="center">Switch to the $[mobile_switch_link].</p> {/if} <div id="user-info" align="center"> {if $[current_user.is_member]} Welcome, $[current_user.name]! <br> <a href="http://evil-incarnate.freeforums.net/user">$[current_user.avatar] </a> <br /><center> Private Messages<br><a href="/conversations/inbox"><b>Inbox:</b></a> <font color="#c5bf9c">$[current_user.messages.inbox]</font> | New: <font color="#c5bf9c"><u>$[current_user.messages.new]</u></font><br><hr><a href="$[logout_link.href]"><b>[Log Out]</b></a> <a href="http://evil-incarnate.freeforums.net/user/$[current_user.id]/avatar"><b>[Edit Profile]</b></a><br><hr><a href="http://evil-incarnate.freeforums.net/?tour=eviltour"><b>[Virtual Website Tour]</b></a> {else} Welcome, Guest! <a href="$[login_link.href]">[login]</a> <a href="$[register_link.href]">[register]</a></center> {/if} </div> <script type="text/javascript"> $(document).ready(function(){ $('#user-info').appendTo('#move-welcome'); }); </script> </body>
</html>
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Apr 18, 2019 15:28:19 GMT -8
If you post your entire template (inside of code tags), someone should be able to see what the issue is. Thanks, Todge ! I was going to do that, but couldn't remember the syntax for it, so I had to go the long route.
<!DOCTYPE HTML> $[tag.html.open] <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>$[title] | $[forum.name]</title> <script type="text/javascript" language=JavaScript src="http://www.evil-incarnate.com/form/browserdetection.js"> </script> $[head] <!-- <div id="navigation-menu" class="ui-helper-clearfix"> <ul role="navigation"> {foreach $[navigation.menu]} <li> <a{if $[navigation.menu.active]} class="state-active"{/if} href="$[navigation.menu.href]"{if $[navigation.menu.accesskey]} accesskey="$[navigation.menu.accesskey]"{/if}> $[navigation.menu.name] {if $[navigation.menu.notification.total]} <div class="tip-holder" onclick="window.location='$[navigation.menu.notification.href]'; return false;"> <div class="tip-number">$[navigation.menu.notification.total]</div> <span class="tip"></span> </div> {/if} </a> </li> {/foreach} </ul> <p id="welcome"> {if $[current_user.is_member]} $[current_user.name] (<a href="$[logout_link.href]">signout</a>) - <a href="/conversations/inbox"><b>Inbox:</b></a> <font color="#c5bf9c">$[current_user.messages.inbox]</font> | New: <font color="#c5bf9c"><u>$[current_user.messages.new]</u></font> {else} Welcome Guest to $[forum.name]. $[login_link.] or $[register_link.] {/if} </p> </div> --> <style type='text/css'>div.peek-a-boo { background : transparent url('https://www.evil-incarnate.com/images/peek_smiley.gif') no-repeat scroll right bottom; bottom : 0; width : 100px; height : 100px; position : fixed; right : 0; } </style> </head> <body><div class='peek-a-boo'></div>
<script> var css = "<style>";
if($[current_user.is_staff]) { css += ".site_admin{ display: block!important; }"; }
if($.inArray(4,pb.data('user').group_ids) != -1) { css += ".clan_member{ display: block!important; }"; } css += "</style>";
$("head").append(css); </script> {if $[maintenance_mode]} <div class="maintenance-header"> {if $[can.disable_maintenance]}<p>Finished with maintenance? $[disable_maintenance_link].</p>{/if} </div> {/if} <div id="wrapper"> <header> <div id="banner-container" role="banner"> <h2 id="banner"> $[forum.title] </h2> </div> <a id="navigation-skip" href="#content" accesskey="s" class="aria-hidden" title="Skip Navigation">Skip Navigation</a> <a href="#" accesskey="d" title="Open Menu" onclick="proboards.hotkeys.activate(Keys.d); return false;"></a> </header> $[participated_threads_link]
<div id="navigation-tree"> $[navigation.tree] </div> $[header] <div id="content" role="main"> {if $[notice]} <div class="container"> <div class="title-bar"><h2>$[notice.title]</h2></div> <div class="content pad-all cap-bottom"> $[notice.message] </div> </div> {/if} $[content] $[shoutbox] </div>
$[footer] <!--- BEGIN CUSTOM EVIL FOOTER --->
<table align="center" cellspacing="0" cellpadding="0" border="0" width="100%"> <tr> <td align="center" valign="top"><div align="center"><div class="container" id="Evil_Footer" style="margin-bottom: 0px;"> <div class="title-bar"> </div> <div class="content pad-all cap-bottom"> <div> <div align='center'>Theme by <a href="http://evil-incarnate.freeforums.net/user/1">Native</a> @ <a href="http://evil-incarnate.freeforums.net/">Evil-Incarnate</a> <br><br>You are visitor # <a href="http://www.hitwebcounter.com" target="_blank"> <img src="http://hitwebcounter.com/counter/counter.php?page=7036917&style=0038&nbdigits=9&type=page&initCount=7277100" title="http://www.hitwebcounter.com/htmltutorial.php" Alt="http://www.hitwebcounter.com/htmltutorial.php" border="0" > </a><br><br><script language="JavaScript"> <!-- //using browserdetection.js if(self.browserName) document.write('' +'Browser name = '+browserName+'<br>' +'Full version = '+fullVersion+'<br>' +'Major version = '+majorVersion+'<br>' +'navigator.appName = '+navigator.appName+'<br>' +'navigator.userAgent = '+navigator.userAgent+'<br>' )
</script> <script type="text/javascript"> var userip; </script> <script type="text/javascript" src="https://l2.io/ip.js?var=userip"></script> <script type="text/javascript"> document.write("Your IP is :", userip); </script></div> </div> </div></div></td> </tr> </table>
<!--- END CUSTOM EVIL FOOTER ---> {if $[is_mobile_browser]} <br /><p class="center">Switch to the $[mobile_switch_link].</p> {/if} <div id="user-info" align="center"> {if $[current_user.is_member]} Welcome, $[current_user.name]! <br> <a href="http://evil-incarnate.freeforums.net/user">$[current_user.avatar] </a> <br /><center> Private Messages<br><a href="/conversations/inbox"><b>Inbox:</b></a> <font color="#c5bf9c">$[current_user.messages.inbox]</font> | New: <font color="#c5bf9c"><u>$[current_user.messages.new]</u></font><br><hr><a href="$[logout_link.href]"><b>[Log Out]</b></a> <a href="http://evil-incarnate.freeforums.net/user/$[current_user.id]/avatar"><b>[Edit Profile]</b></a><br><hr><a href="http://evil-incarnate.freeforums.net/?tour=eviltour"><b>[Virtual Website Tour]</b></a> {else} Welcome, Guest! <a href="$[login_link.href]">[login]</a> <a href="$[register_link.href]">[register]</a></center> {/if} </div> <script type="text/javascript"> $(document).ready(function(){ $('#user-info').appendTo('#move-welcome'); }); </script> </body>
</html>
I can't find the links that the code works with..
|
|
irontongue
New Member
Headed to the gym.
Posts: 82
inherit
257751
0
Apr 21, 2021 3:35:54 GMT -8
irontongue
Headed to the gym.
82
February 2019
irontongue
|
Post by irontongue on Apr 19, 2019 11:19:56 GMT -8
Todge <div style="display: none;" class="site_admin"><img src="//storage.proboards.com/7032343/images/rMEZvBHSNxqzNjXJbbQU.gif"> <a href="http://evil-incarnate.freeforums.net/admin">Site Admin</a></div>
<div style="display: none;" class="clan_member"><img src="//storage.proboards.com/7032343/images/rMEZvBHSNxqzNjXJbbQU.gif"> <a href="http://evil-incarnate.freeforums.net/page/some_random_page">Clan Only Image Hosting</a></div>
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Apr 19, 2019 14:12:01 GMT -8
Todge <div style="display: none;" class="site_admin"><img src="//storage.proboards.com/7032343/images/rMEZvBHSNxqzNjXJbbQU.gif"> <a href="http://evil-incarnate.freeforums.net/admin">Site Admin</a></div>
<div style="display: none;" class="clan_member"><img src="//storage.proboards.com/7032343/images/rMEZvBHSNxqzNjXJbbQU.gif"> <a href="http://evil-incarnate.freeforums.net/page/some_random_page">Clan Only Image Hosting</a></div> The code works fine with those links, at least for me on my test forum. Can you please post the full template, with the links in place, so I can take a look, as the template you posted above does not include them.
|
|
irontongue
New Member
Headed to the gym.
Posts: 82
inherit
257751
0
Apr 21, 2021 3:35:54 GMT -8
irontongue
Headed to the gym.
82
February 2019
irontongue
|
Post by irontongue on Apr 20, 2019 11:20:32 GMT -8
Those links are part of a custom navigation menu I created with Sidebar Redux Plugin.
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Apr 20, 2019 16:10:58 GMT -8
Those links are part of a custom navigation menu I created with Sidebar Redux Plugin. If the links are being added with a plugin, that COULD explain why they are not being seen, as the links are being added after the page, including the script we are using, has been rendered. Try removing the current code, and try adding this to the bottom of the Forum Wrapper Template instead.. <script> $(document).ready(function() { if(pb.data('user').is_staff == 1) { $('.site_admin').each(function(){ $(this).css('display', 'block'); }); } if($.inArray(6,pb.data('user').group_ids) != -1) { $('.clan_member').each(function(){ $(this).css('display', 'block'); }); } }); </script>
If that still fails then try putting it in your Global FOOTER instead.
|
|
irontongue
New Member
Headed to the gym.
Posts: 82
inherit
257751
0
Apr 21, 2021 3:35:54 GMT -8
irontongue
Headed to the gym.
82
February 2019
irontongue
|
Post by irontongue on Apr 21, 2019 4:58:49 GMT -8
Those links are part of a custom navigation menu I created with Sidebar Redux Plugin. If the links are being added with a plugin, that COULD explain why they are not being seen, as the links are being added after the page, including the script we are using, has been rendered. Try removing the current code, and try adding this to the bottom of the Forum Wrapper Template instead.. <script> $(document).ready(function() { if(pb.data('user').is_staff == 1) { $('.site_admin').each(function(){ $(this).css('display', 'block'); }); } if($.inArray(6,pb.data('user').group_ids) != -1) { $('.clan_member').each(function(){ $(this).css('display', 'block'); }); } }); </script>
If that still fails then try putting it in your Global FOOTER instead. Thanks, I'll try that later when I get home from church.
Happy Resurrection Day!
|
|
irontongue
New Member
Headed to the gym.
Posts: 82
inherit
257751
0
Apr 21, 2021 3:35:54 GMT -8
irontongue
Headed to the gym.
82
February 2019
irontongue
|
Post by irontongue on Apr 21, 2019 13:24:24 GMT -8
TodgeI placed it in the global header and it works just fine, ty. So much help. You're a gem Todge.
|
|
#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,324
January 2004
todge
|
Post by Todge on Apr 22, 2019 11:29:56 GMT -8
No worries...
|
|