vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   plugin conditional help (https://vborg.vbsupport.ru/showthread.php?t=279768)

tommyxv 03-08-2012 07:25 PM

plugin conditional help
 
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?

Code:

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&amp;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>';


kh99 03-08-2012 07:29 PM

If think you'd want:

Code:

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

Quote:

Originally Posted by kh99 (Post 2307603)
If think you'd want:

Code:

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??

kh99 03-08-2012 08:24 PM

Quote:

Originally Posted by tommyxv (Post 2307623)
How do I declare $vbulletin as global??


Just add it to your first line, like:

Code:

global $template_hook, $vbulletin;

tommyxv 03-08-2012 08:30 PM

Code:

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&amp;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.

kh99 03-08-2012 08:42 PM

You put it in the middle of the string. You need to do something like this:

PHP Code:

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&amp;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->userinfo6))
{
   
$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.

kh99 03-08-2012 08:57 PM

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:

PHP Code:

//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...
Code:

$tablinks .=
Would that effect it?

kh99 03-08-2012 09:00 PM

Quote:

Originally Posted by tommyxv (Post 2307644)
I'll try that...

I noticed that the dot is missing for some of the tablinks...
Code:

$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.


All times are GMT. The time now is 12:06 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01178 seconds
  • Memory Usage 1,757KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete