• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Add own Navigation Tabs

  • Thread starter Thread starter ragtek
  • Start date Start date
After reading this and being VERY hesitant to ruining my current forums... While this 'very basic tutorial' explains how to add extra navtabs on top... i'm still puzzled with this "Create a Code Event Listener which "listens" to navigation tab" part.. i have NO clue where to put this in at... the forum does not have any EASY way of adding simple basic navtab on top via the ACP?!
 
. the forum does not have any EASY way of adding simple basic navtab on top via the ACP?!
No, not ATM :(


You need to enable the debug mod.
Then you can create new code events...

Yes, it is very complicated :(
 
No, not ATM :(


You need to enable the debug mod.
Then you can create new code events...

Yes, it is very complicated :(
well i can handle perl/php/java/c# - whatev... but i've seen 10-20+ xenforo forums with navtabs up top to link to simple things like: Staff, Pages/*, Chat, Donate

How are they ALL doing that? It must be something really obvious and simple, eh?

Indeed it was simple.. but knowing where to look is key, this is the thread that made it all happen:

http://xenforo.com/community/threads/how-to-add-a-new-tab-in-the-navbar.7781/
 
So, this Is what I did:

  • Created a phrase named blog_navbar_tab
  • Created a folder named DFTAb and placed DFTab.php file in with following content:
PHP:
<?php
class DFTab_DFTab
{
  /**
     * add the "info" tab to the navbar
     * @param array $extraTabs
     * @param string $selectedTabId
     */
    public static function addNavbarTab(array &$extraTabs, $selectedTabId)
    {
        $extraTabs['info'] = array(
            'title' => new XenForo_Phrase('blog_navbar_tab'),//phrase with the title for the link
            'href'   => XenForo_Link::buildPublicLink('http://www.siteadress/blog'),
            'linksTemplate' => 'ragtek_infopage_navbar',      //if you want to have a "sub menu" you can create a template for this
            'position'  =>  'middle'  //since beta 5, you can choose the position, where the link should be placed      possible positions: [SIZE=3][FONT=Arial]middle end home[/FONT][/SIZE]
        );
    }
}

  • Uploaded DFTab folder to /library
  • After that I went to the development tab in my admincp and clicked on; 'Code Event Listeners' - 'Create New Code Event Listener'
  • From Listen to Event, I selected navigation_tabs
  • Execute Callback: DFTab_DFTab :: addNavbarTab
  • And saved it.
That's about it !
 
Where did you create the folder?
In the library or the xenforo directory?
 
you didn't place it in the xenforo directory, so why do you have xenforo in your classname?

if your class is placed in /library/DFTab/DFTab.php the classname is:
DFTab_DFTab
 
you didn't place it in the xenforo directory, so why do you have xenforo in your classname?

if your class is placed in /library/DFTab/DFTab.php the classname is:
DFTab_DFTab

Because maybe I'm an idiot :D
Sorry ragtek, the whole time I'm thinking XenForo is necessary there and going bananas :D
The terrible result of not knowing anything about code :D
 
Hey guys. I need some help please. I have been playing with this code for the past 2 hours but i'm still stuck. The new tab is showing and it works OK but it does not stay selected when i click on it. What am i doing wrong? I would post my code but i would just be duplicating whats been posted already. Any tips on what i should look for?

Thanks!
 
To which page are you linking?
It's important that the array key have the same value as the last route parameter (don't know how to call it:D )
$extraTabs['info']
 
Here is the code i'm using. Hopefully I did it right.

My listner file is under /library/Radio/tab.php

Code:
<?php class Radio_tab
{
     public static function addNavbarTab(array &$extraTabs, $selectedTabId)
    {
        $extraTabs['Radio'] = array(
            'title' => new XenForo_Phrase('radio_navtab'),
            'href'   => XenForo_Link::buildPublicLink('pages/radio'),
            'selected'  =>  ($selectedTabId == 'Radio'),
//           'linksTemplate' => '',
            'position'  =>  'middle',
        );
    }
}

I'm certain the code event listener is setup correctly.

Thanks for your help!
biggrin.png
 
Goodness what a carry on to add a link
blink.gif


I don't even know what ragtek meant by "add this class to the xenforo directory"

If I am lost on the very first instruction, it doesn't bode well for doing this myself.

What xenforo directory?

Can someone explain this on NON coder terms please.

Thanks :)
 
Back
Top Bottom