• 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
Development tab in the Admin CP.. click on Code Event Listeners..

This will list all the addons that have Code Event Listeners. Each Addon is identified with BOLD Font. Each Addon that has a "Tab" will have a navigation_tabs entry.
Ahh lol yea forgot about that in there
Thanks!
 
A quick note:

If you use a phrase for the tab title, you SHOULD cache the phrase.
This will save you an global DB Query!
 
I really don't understand this at all as the first post isn't too clear.

Can someone give me a real simple rundown of how to use this properly. Saying things like " Create a Code Event Listener which "listens" to navigation tab" makes no sense to me.

Can someone give me a step by step guide to using this? The first post doesn't list what folder to upload the created class to either.
 
Create a code event listener: admin.php?code-event-listeners/add
That listens to navigation tab:
5FrJ.jpeg


You need to enable debug mode in order to do that though.

1. Create your classfile in the xenforo directory. I named it ragtekTab
The XenForo directory - i.e. library/XenForo/ragtekTab.php
 
Thanks as to me the xenforo directory is your forum folder, that would be the library xenforo folder, think the post needs to be made a little bit clearer.

I know it's being anal but it just makes it clearer.

Ps. Where do i enable debug mode?
 
All this to add a navigation tab, christ, up until now xenforo has been so easy. This really needs to be improved (already added my small feature request to relevent forum).
 
Would it be possible for this just to be an addon so people like me don't have to get frustrated with editing all these things, i would love that.

Giving it a go now though.

If i have created a page in the nodes admin and want my tab to link to it, what would i put in the href section? The page url bit is "about_us".
 
How do I enable debug mode?
Edit the /library/config.php file to add the following line: $config['debug'] = true;
Note that it is not advised to run a live site with debug mode enabled due to the increased resources required.

http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-182355
Kinda relevant but you might wanna add to that how to enable debug mode for your own IP:
Code:
if($_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx') // your IP
{
    $config['debug'] = true;
}
 
Thanks James, I've got a huge list of updates for the FAQs and Help Manual so I'll add that to the list (y)
 
Would it be possible for this just to be an addon so people like me don't have to get frustrated with editing all these things, i would love that.

Giving it a go now though.

If i have created a page in the nodes admin and want my tab to link to it, what would i put in the href section? The page url bit is "about_us".
I'm not 100% sure but try putting the href as 'pages/about_us'. If that doesn't work, try putting it as XenForo_Link::buildPublicLink('pages/about_us');
(All single quotes included)
 
Right will try that, although when trying to add a code event listener i am getting this error:

Please enter a valid callback method.

Honestly i really don't understand what i am doing, would be so much easier as a plugin <_<

I named my file "navtabs.php", the class is named "navtabs", and function is "addNavbarTab".

So i put navtabs i the class input and "addNavbarTab" in the Method input.
 
You need to create the file before you can add the code event listener callback.

Once you've created the PHP file and saved it in library/XenForo/ragtekTab.php, you can add the following to Execute Callback:
Code:
xenforo_ragtekTab :: addNavbarTab

See:
58431a7efb964dfd8df679a.png
 
The problem is when you rename files it becomes difficult to name them. The XenForo preloader relies on file names.

The file is called navtabs.php? Execute your callback as:
XenForo_navtabs :: addNavbarTabs
 
Top Bottom