View Single Post
  #88  
Old 12-10-2011, 09:42 PM
Dax IX Dax IX is offline
 
Join Date: Jul 2005
Posts: 153
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent tutorial!

I have a question about using this with vBa CMPS...I'd like the subnav links to be the various pages of my vBa CMPS. Basically I want the links in the Site Navigation module to show in my navbar.

I've pieced a few things together, but obviously I've done something horribly wrong as they aren't working...

I basically just copied and pasted code, so some of this code is not playing well with other parts. I just need to figure out where I need to change things...

Here's my plugin code:
PHP Code:
$navigationbits = array();

if (!empty(
$vbulletin->adv_portal_page))
{
    
$navpages array_keys($vbulletin->adv_portal_page);
}

if (!empty(
$mod_options['portal_navigation_excludepages']))
{
    
$navpages array_diff($navpages$mod_options['portal_navigation_excludepages']);
}

(
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_start')) ? eval($hook) : false;

if (!empty(
$navpages))
{
    eval(
'$mod_options[\'portal_navigation_mark1\'] = "' addslashes($mod_options['portal_navigation_mark1']) . '";');
    eval(
'$mod_options[\'portal_navigation_mark2\'] = "' addslashes($mod_options['portal_navigation_mark2']) . '";');

    foreach (
$navpages AS $npageid)
    {
        
$npage =& $vbulletin->adv_portal_page[$npageid];

        if (!
array_intersect($vbulletin->userinfo['usergrouparray'], $npage['userperms']))
        {
            continue;
        }

        if (
$npage['level'] <= 1)
        {
            
$navigationbits[$npageid]['navmark'] = $mod_options['portal_navigation_mark1'];
        }
        else
        {
            
$navigationbits[$npageid]['navmark'] = str_repeat('&nbsp;', (intval($npage['level'] - 1))) . $mod_options['portal_navigation_mark2'];
        }

        
$navigationbits[$npageid]['link'] = $vba_options['portal_homeurl'] . ($npage['name'] != 'home' '?' $vbulletin->session->vars['sessionurl'] . $vba_options['portal_pagevar'] . '=' $npage['name'] : '');
        
$navigationbits[$npageid]['title'] = ($npageid == $pages['pageid']) ? '<strong>' $npage['title'] . '</strong>' $npage['title'];

        (
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_def_pagebits')) ? eval($hook) : false;
    }
}

// Additional pages
$customnavigationbits = array();

if (!empty(
$mod_options['portal_navigation_addpages']))
{
    foreach (
$mod_options['portal_navigation_addpages'] AS $key => $navlinks)
    {
        
$customnavigationbits[$key]['title'] = $navlinks['text'];
        eval(
'$customnavigationbits[$key][\'link\'] = "' addslashes($navlinks['link']) . '";');

        if (
$navlinks['level'] <= 1)
        {
            
$customnavigationbits[$key]['navmark'] = $mod_options['portal_navigation_mark1'];
        }
        else
        {
            
$customnavigationbits[$key]['navmark'] = str_repeat('&nbsp;'intval($navlinks['level'] - 1)) . $mod_options['portal_navigation_mark2'];
        }

        (
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_cus_pagebits')) ? eval($hook) : false;
    }
}

(
$hook vBulletinHook::fetch_hook('vba_cmps_module_navigation_end')) ? eval($hook) : false;

$templater vB_Template::create('portal_navbar');
$templater->register('customnavigationbits'$customnavigationbits);
$templater->register('navigationbits'$navigationbits);
$home["$mods[modid]"]['content'] = $templater->render();


if (
THIS_SCRIPT == 'adv_index')  // also defined('ragteknews') possible
{
//set selected tab
    
$vbulletin->options['selectednavtab'] = 'portal';
}
// add the "subtemplate" to the navbartemplate
$template_hook['navtab_start'] .= vB_Template::create('portal_navbar')->render(); 
(with parts taken directly from the navigation.php module code)

and my template code:
HTML Code:
<vb:if condition="$vboptions['selectednavtab'] == 'portal'">
<li class="selected">
    <a class="navtab" href="/index.php{vb:raw session.sessionurl_q}">Home</a>
<ul class="floatcontainer">
    <vb:each from="navigationbits" value="page">
        <li>{vb:raw page.navmark} <vb:if condition="$page['link']"><a href="{vb:raw page.link}">{vb:raw page.title}</a><vb:else />{vb:raw page.title}</vb:if></li>
    </vb:each> 
       <vb:each from="customnavigationbits" value="page">
        <li>{vb:raw page.navmark} <vb:if condition="$page['link']"><a href="{vb:raw page.link}">{vb:raw page.title}</a><vb:else />{vb:raw page.title}</vb:if></li>
    </vb:each></ul>
</li>
<vb:else />
<li><a class="navtab" href="/index.php{vb:raw session.sessionurl_q}">Home</a></li>
</vb:if>
(with parts taken from the adv_portal_navigation template)

Where am I going wrong?
(I'm obviously NOT a coder...)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01225 seconds
  • Memory Usage 1,840KB
  • 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
  • (1)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