Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Displaying tabs in side panel

edited March 2010 in Vanilla 1.0 Help
Vanilla 1.1.10

I'm trying to display the menu tabs in the side panel through a theme. I've taken the chunk of code that produces the tabs in \themes\mytheme\menu.php and have put it in \themes\mytheme\panel.php like this:

echo '<div id="navigation">';
echo ' <ul>';
while (list($Key, $Tab) = each($this->Tabs)) {
echo ' <li'.$this->TabClass($this->CurrentTab, $Tab['Value']).'><a href="'.$Tab['Url'].'" '.$Tab['Attributes'].'>'.$Tab['Text'].'</a></li>';
}
echo ' </ul>';
echo '</div>';
When a page is rendered, the html contains the navigation div and the ul tags but no list items. Clearly, $this->Tabs contains nothing or isn't set within the panel module. Is there something I need to do to populate the TAbs array?

Cheers.

Comments

  • I've changed tack and put the following code in an extension. It works for the most part, but for some reason the class (css) for the current tab isn't being set to "TabOn".

    I'm not sure I understand what's happening with the TablClass function.
    Any thoughts?

    $Context->Dictionary['TabsNav'] = 'Navigation';

    // Create navigation list
    $Nav = '<div id="navigation">';
    $Nav .= ' <ul>';
    while (list($Key, $Tab) = each($Menu->Tabs)) {
    $Nav .= ' <li'.$Menu->TabClass($Menu->CurrentTab, $Tab['Value']).'><a href="'.$Tab['Url'].'" '.$Tab['Attributes'].'>'.$Tab['Text'].'</a></li>';
    }
    $Nav .= ' </ul>';
    $Nav .= '</div>';

    // Add list to the panel
    $Panel->AddString($Nav);

    // Add the style to the head
    $Head->AddStyleSheet("extensions/PanelTabs/style.css", "screen");

  • I've traced $Menu->CurrentTab and turns out it's not set (has no value) inside the extension. To work around it I use the filename substring from $Context->SelfUrl. Completely inelegant I know, and I also had to account for it returning "index" for discussions.php, but it does the job.

    Final code:

    $Context->Dictionary['TabsNav'] = 'Navigation';

    $CurTab = substr($Context->SelfUrl, 0,strrpos($Context->SelfUrl,'.'));
    if ($CurTab == "index") $CurTab = "discussions";

    // Create navigation list
    $Nav = '<div id="navigation">';
    $Nav .= ' <ul>';
    while (list($Key, $Tab) = each($Menu->Tabs)) {
    $Nav .= ' <li'.$Menu->TabClass($CurTab, $Tab['Value']).'><a href="'.$Tab['Url'].'" '.$Tab['Attributes'].'>'.$Tab['Text'].'</a></li>';
    }
    $Nav .= ' </ul>';
    $Nav .= '</div>';

    // Add list to the panel
    $Panel->AddString($Nav);

    Well, I've enjoyed discussing this with myself. It's really helped me work through it and find a solution. Hope someone else finds it useful too.
  • Thanks for all the hard work! Do you have an example of this online anywhere so we can take a look? Also, are you going to share your theme (not necessarily the style) with the community?
Sign In or Register to comment.