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(' ', (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(' ', 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...)