View Single Post
  #68  
Old 03-24-2010, 12:47 PM
Sarcoth Sarcoth is offline
 
Join Date: Mar 2006
Location: Huntsville
Posts: 521
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I finally figured out a way to add all my variables from my custom page to the navbar. I went about it in a sneaky way.

I first added the following code to my showroster.php file which allowed me to add all the registered variables I wanted to use:

PHP Code:
$accessgroups explode(','$vbulletin->options['showroster_access_groups']);
$navbarloc $vbulletin->options['showroster_navbar_loc'];

switch (
$navbarloc) {
    case 
'1':
        
$nbloc 'navtab_start'; break;
    case 
'2':
        
$nbloc 'navtab_middle'; break;
    case 
'3':
        
$nbloc 'navtab_end'; break;
}

if (
THIS_SCRIPT == 'showroster') {
    
$vbulletin->options['selectednavtab'] = 'showroster'
}

$templater vB_Template::create('showroster_navbar');
    
$templater->register('sorturl'$sorturl);
    
$templater->register('accessgroups'$accessgroups);
    
$templater->register('columns'$columns);
    
$templater->register('sortgroupfield'$sortgroupfield);
    
$templater->register('oppositesort'$oppositesort);
$template_hook[$nbloc] .= $templater->render(); 
Since that was a close repeat to the code in my plugin, I ended up having one Roster button when on another tab and two when viewing the roster. I tried to remove the plugin, but that then caused the button to be missing when on another page; although it was there when on the roster. It makes sense after the fact. So, after some thought, I changed my plugin to the following:

PHP Code:
if (THIS_SCRIPT != 'showroster') {
$accessgroups explode(','$vbulletin->options['showroster_access_groups']);
$navbarloc $vbulletin->options['showroster_navbar_loc'];
$navbarorder $vbulletin->options['showroster_navbar_order']; 

switch (
$navbarloc) {
    case 
'1':
        
$nbloc 'navtab_start'; break;
    case 
'2':
        
$nbloc 'navtab_middle'; break;
    case 
'3':
        
$nbloc 'navtab_end'; break;
}

$templater vB_Template::create('showroster_navbar');
    
$templater->register('accessgroups'$accessgroups);
$template_hook[$nbloc] .= $templater->render();

That allowed me to use the plugin code when not on the roster page. When on the roster page, this code doesn't work, but the code from my showroster.php does. I then set up my showroster_navbar template to include the variables from my .php file and they work very well.

HTML Code:
<vb:if condition="is_member_of($bbuserinfo, $accessgroups)">
<vb:if condition="$vboptions['selectednavtab'] == 'showroster'">
<li class="selected">
	<a class="navtab" href="showroster.php{vb:raw session.sessionurl_q}">Roster</a>
	<ul class="floatcontainer">
		<li><a href="showroster.php{vb:raw session.sessionurl_q}">Default Sort</a></li>
		<li class="popupmenu">
			<a href="javascript://" class="popupctrl">Sorting Options</a>
			<ul class="popupbody popuphover">
				<vb:if condition="$show[field1st]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column1]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts1}</vb:if>&amp;sortgroupfield={vb:raw columns.column1}">{vb:raw columns.title1}</a></li></vb:if>
				<vb:if condition="$show[field2nd]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column2]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts2}</vb:if>&amp;sortgroupfield={vb:raw columns.column2}">{vb:raw columns.title2}</a></li></vb:if>
				<vb:if condition="$show[field3rd]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column3]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts3}</vb:if>&amp;sortgroupfield={vb:raw columns.column3}">{vb:raw columns.title3}</a></li></vb:if>
				<vb:if condition="$show[field4th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column4]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts4}</vb:if>&amp;sortgroupfield={vb:raw columns.column4}">{vb:raw columns.title4}</a></li></vb:if>
				<vb:if condition="$show[field5th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column5]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts5}</vb:if>&amp;sortgroupfield={vb:raw columns.column5}">{vb:raw columns.title5}</a></li></vb:if>
				<vb:if condition="$show[field6th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column6]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts6}</vb:if>&amp;sortgroupfield={vb:raw columns.column6}">{vb:raw columns.title6}</a></li></vb:if>
				<vb:if condition="$show[field7th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column7]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts7}</vb:if>&amp;sortgroupfield={vb:raw columns.column7}">{vb:raw columns.title7}</a></li></vb:if>
				<vb:if condition="$show[field8th]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == $columns[column8]">{vb:raw oppositesort}<vb:else />{vb:raw columns.sorts8}</vb:if>&amp;sortgroupfield={vb:raw columns.column8}">{vb:raw columns.title8}</a></li></vb:if>
				<vb:if condition="$show[datejoinedcol]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == 'joindate'">{vb:raw oppositesort}<vb:else />{vb:raw columns.sortsdj}</vb:if>&amp;sortgroupfield=joindate">{vb:rawphrase join_date}</a></li></vb:if>
				<vb:if condition="$show[lastactivecol]"><li><a href="{vb:raw sorturl}&amp;order=<vb:if condition="$sortgroupfield == 'lastactive'">{vb:raw oppositesort}<vb:else />{vb:raw columns.sortsla}</vb:if>&amp;sortgroupfield=lastactive">{vb:rawphrase last_activity}</a></li></vb:if>
			</ul>
		</li>
	</ul>
</li>
<vb:else />
<li><a class="navtab" href="showroster.php{vb:raw session.sessionurl_q}">Roster</a></li>
</vb:if>
</vb:if>
I'm not saying this is the best way, far from it. I would much rather have had a way to pull the data from my .php to the plugin and then use it in the template that way, but this works for now. I'll gladly accept a better way if someone can tell me. I'm sure I'm added more code than I need.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01309 seconds
  • Memory Usage 1,845KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete