Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2012, 07:25 PM
tommyxv tommyxv is offline
 
Join Date: Feb 2005
Posts: 295
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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>';
Reply With Quote
  #2  
Old 03-08-2012, 07:29 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If think you'd want:

Code:
if (is_member_of($vbulletin->userinfo, 6))
{
   // admins only
}

You may also need to declare $vbulletin as global.
Reply With Quote
  #3  
Old 03-08-2012, 08:22 PM
tommyxv tommyxv is offline
 
Join Date: Feb 2005
Posts: 295
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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??
Reply With Quote
  #4  
Old 03-08-2012, 08:24 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tommyxv View Post
How do I declare $vbulletin as global??

Just add it to your first line, like:

Code:
global $template_hook, $vbulletin;
Reply With Quote
  #5  
Old 03-08-2012, 08:30 PM
tommyxv tommyxv is offline
 
Join Date: Feb 2005
Posts: 295
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 03-08-2012, 08:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>'
Reply With Quote
Благодарность от:
tommyxv
  #7  
Old 03-08-2012, 08:46 PM
tommyxv tommyxv is offline
 
Join Date: Feb 2005
Posts: 295
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That made the plugin to stop working. Any more ideas? Thanks for the help BTW.
Reply With Quote
  #8  
Old 03-08-2012, 08:57 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>'; 
//} 
Reply With Quote
  #9  
Old 03-08-2012, 08:59 PM
tommyxv tommyxv is offline
 
Join Date: Feb 2005
Posts: 295
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll try that...

I noticed that the dot is missing for some of the tablinks...
Code:
$tablinks .=
Would that effect it?
Reply With Quote
  #10  
Old 03-08-2012, 09:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tommyxv View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04479 seconds
  • Memory Usage 2,280KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete