Okay... how would I ITERATE this?
For instance... this is my navtab template:
Code:
<vb:if condition="$vboptions['selectednavtab'] == 'media'">
<li class="selected">
<a class="navtab" href="media.php{vb:raw session.sessionurl_q}">Media</a>
<ul class="floatcontainer">
<li><a href="media.php{vb:raw session.sessionurl_q}">Media Home</a></li>
<li class="popupmenu">
<a href="javascript://" class="popupctrl">Categories</a>
<ul class="popupbody popuphover">
{vb:raw catbits}
</ul>
</li>
</ul>
</li>
<vb:else />
<li><a class="navtab" href="media.php{vb:raw session.sessionurl_q}">Media</a></li>
</vb:if>
You'll notice, instead of the actual subbits, I have a raw variable called "catbits". The code for getting the catbits would be as follows:
Code:
$categories = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "media_category");
while ($category = $vbulletin->db->fetch_array($categories))
{
$templater = vB_Template::create('media_NAVTAB_bit');
$templater->register('categoryID', $category['categoryID']);
$templater->register('catName', $category['catName']);
$catbits .= $templater->render();
}
Where would I put this code? And how do I register the $catbits variable into the hook?
--------------- Added [DATE]1269835210[/DATE] at [TIME]1269835210[/TIME] ---------------
Okay... trying things out, I was able to get it working by using this plugin....
Code:
if (THIS_SCRIPT == 'media')
{
$vbulletin->options['selectednavtab'] = 'media';
}
$categories = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "media_category");
while ($category = $vbulletin->db->fetch_array($categories))
{
$templater = vB_Template::create('media_NAVTAB_bit');
$templater->register('categoryID', $category['categoryID']);
$templater->register('catName', $category['catName']);
$catbits .= $templater->render();
}
$templater = vB_Template::create('media_NAVTAB');
$templater->register('catbits', $catbits);
$template_hook['navtab_middle'] .= $templater->render();
However, obviously this adds an extra query on EVERY page. Is there a better way to do this?