View Full Version : plugin conditional help
tommyxv
03-08-2012, 07:25 PM
I can't figure out how to put a usergroup conditional to show a link to just admin in this plugin that adds nav links in my PP Gallery....I tried a few but none worked.
Any Ideas?
global $template_hook;
$tabselected = '';
$tablinks = '';
if (PP_SCRIPT == 'PP_Pro')
{
$vbulletin->options['selectednavtab']='pp_pro';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="http://www.mysite.com/gallery/index.php">Gallery Home</a></li>
<li><a href="http://www.mysite.com/gallery/showgallery.php?cat=500&ppuser=$vbuserid">My Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php?what=fav">My Favorites</a></li>
<li><a href="http://www.mysite.com/gallery/useralbums.php">My Albums</a></li>
<li><a href="http://www.mysite.com/gallery/uploadphoto.php">Upload Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php">Search</a></li>
I WANT TO ADD CONDITIONAL HERE <li>LINK FOR ADMINS</li> END CONDITIONAL
</ul> ';
}
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.mysite.com/gallery/">Gallery</a>'.$tablinks.'</li>';
If think you'd want:
if (is_member_of($vbulletin->userinfo, 6))
{
// admins only
}
You may also need to declare $vbulletin as global.
tommyxv
03-08-2012, 08:22 PM
If think you'd want:
if (is_member_of($vbulletin->userinfo, 6))
{
// admins only
}
You may also need to declare $vbulletin as global.
How do I declare $vbulletin as global??
How do I declare $vbulletin as global??
Just add it to your first line, like:
global $template_hook, $vbulletin;
tommyxv
03-08-2012, 08:30 PM
global $template_hook, $vbulletin;
$tabselected = '';
$tablinks = '';
if (PP_SCRIPT == 'PP_Pro')
{
$vbulletin->options['selectednavtab']='pp_pro';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="http://www.mysite.com/gallery/index.php">Gallery Home</a></li>
<li><a href="http://www.mysite.com/gallery/showgallery.php?cat=500&ppuser=$vbuserid">My Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php?what=fav">My Favorites</a></li>
<li><a href="http://www.mysite.com/gallery/useralbums.php">My Albums</a></li>
<li><a href="http://www.mysite.com/gallery/uploadphoto.php">Upload Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php">Search</a></li>
if (is_member_of($vbulletin->userinfo, 6))
{
<li> link here </li>
}
</ul> ';
}
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.mysite.com/gallery/">Gallery</a>'.$tablinks.'</li>';
Hmmm, I tried the code above, but no luck.. It just shows the conditional text and link.
Im using global_state_check as the hook location, if that helps.
You put it in the middle of the string. You need to do something like this:
global $template_hook, $vbulletin;
$tabselected = '';
$tablinks = '';
if (PP_SCRIPT == 'PP_Pro')
{
$vbulletin->options['selectednavtab']='pp_pro';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="http://www.mysite.com/gallery/index.php">Gallery Home</a></li>
<li><a href="http://www.mysite.com/gallery/showgallery.php?cat=500&ppuser=$vbuserid">My Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php?what=fav">My Favorites</a></li>
<li><a href="http://www.mysite.com/gallery/useralbums.php">My Albums</a></li>
<li><a href="http://www.mysite.com/gallery/uploadphoto.php">Upload Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php">Search</a></li>';
if (is_member_of($vbulletin->userinfo, 6))
{
$tablinks .= '<li> link here </li>';
}
$tablinks .= '</ul> ';
}
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.mysite.com/gallery/">Gallery</a>'.$tablinks.'</li>';
tommyxv
03-08-2012, 08:46 PM
That made the plugin to stop working. Any more ideas? Thanks for the help BTW.
Hmm...I don't see anything wrong with it. Try temporarily removing the 4 lines starting with the 'if' and see if the plugin works (without the admin link of course).
edit: or comment them out like this:
//if (is_member_of($vbulletin->userinfo, 6))
//{
// $tablinks .= '<li> link here </li>';
//}
tommyxv
03-08-2012, 08:59 PM
I'll try that...
I noticed that the dot is missing for some of the tablinks...
$tablinks .=
Would that effect it?
I'll try that...
I noticed that the dot is missing for some of the tablinks...
$tablinks .=
Would that effect it?
The dot means you're adding to the string instead of setting it, so it should only be on some one them.
tommyxv
03-08-2012, 09:04 PM
global $template_hook; $vbulletin;
$tabselected = '';
$tablinks = '';
if (PP_SCRIPT == 'PP_Pro')
{
$vbulletin->options['selectednavtab']='pp_pro';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="http://www.mysite.com/gallery/index.php">Gallery Home</a></li>
<li><a href="http://www.mysite.com/gallery/showgallery.php?cat=500&ppuser=$vbuserid">My Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php?what=fav">My Favorites</a></li>
<li><a href="http://www.mysite.com/gallery/useralbums.php">My Albums</a></li>
<li><a href="http://www.mysite.com/gallery/uploadphoto.php">Upload Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php">Search</a></li>
// if (is_member_of($vbulletin->userinfo, 6))
//{
//$tablinks .= '<li> link here </li>';
//}
$tablinks .= '</ul> ';
}
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.mysite.com/gallery/">Gallery</a>'.$tablinks.'</li>';
The plugin is still not working now. hmmmm.
Oh, now I see, you missed the close quote and semicolon at the end of the line before the if. (You need to scroll right on my post #6 to see it).
tommyxv
03-08-2012, 09:08 PM
global $template_hook; $vbulletin;
$tabselected = '';
$tablinks = '';
if (PP_SCRIPT == 'PP_Pro')
{
$vbulletin->options['selectednavtab']='pp_pro';
$tabselected = ' class="selected"';
$tablinks = ' <ul class="floatcontainer">
<li><a href="http://www.mysite.com/gallery/index.php">Gallery Home</a></li>
<li><a href="http://www.mysite.com/gallery/showgallery.php?cat=500&ppuser=$vbuserid">My Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php?what=fav">My Favorites</a></li>
<li><a href="http://www.mysite.com/gallery/useralbums.php">My Albums</a></li>
<li><a href="http://www.mysite.com/gallery/uploadphoto.php">Upload Photos</a></li>
<li><a href="http://www.mysite.com/gallery/search.php">Search</a></li>
// if (is_member_of($vbulletin->userinfo, 6))
//{
//$tablinks .= '<li> link here </li>';
//}
</ul> ';
}
$template_hook['navtab_middle'] .= '<li'.$tabselected.'><a class="navtab" href="http://www.mysite.com/gallery/">Gallery</a>'.$tablinks.'</li>';
It works this way when i change
$tablinks .= '</ul> ';
to
</ul> ';
Right, OK, but now you're pretty much back to where you started. If there are no other chnages, just copy what I posted in post 6 and try that. (Unless you're not posting the actual plugin code - then you'll have to look again at that line before the 'if' line).
tommyxv
03-08-2012, 09:11 PM
Oh, now I see, you missed the close quote and semicolon at the end of the line before the if. (You need to scroll right on my post #6 to see it).
I must be blind... you point this out.
EDIT:
That is all the of plugin code.
So is it working now? Or are you asking me to point out the missing part I was talking about? It's at the end of this line:
<li><a href="http://www.mysite.com/gallery/search.php">Search</a></li>';
tommyxv
03-08-2012, 09:17 PM
Yes, the plugin and admin link are working now. Thank you so much! I been trying to fix this for weeks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.