• 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
I think I found a better way to do this, if you just want to reefer a link to somewhere.

In the navigation template just add before the part that says "<!-- no selection -->" if you want to be the last link, else just do it before the one that you want.
In this example, I used my clan's radio link.

Code:
<!-- radio -->
		<li class="navTab radio PopupClosed"><a href="http://radio.superialbuilders.com" class="navLink">Radio</a></li>

You can see two examples in my clan forums:
http://forums.superialbuilders.com


Thank you for this Jose! Works great if you just want a link :)
 
Thank you for this Jose! Works great if you just want a link :)
No problem, I'm glad that I helped, I didn't understand the instructions neither, but I gone exploring the templates, and with a bit of trial and error, because I'm no coder on HTML, PHP or CSS, I managed to find that way to do the nav tab.
Now, just waiting that Xenforo goes gold so I can update and check the templates of my new forum design, based on the old one but with more stuff.
 
I can't get this thing to work correctly, well the tab is not being selected.

I created an add-on:
addon.webp

Then I opened my ftp and created under Library the following directories: Biblioteca>Listeners

Then I created a Tabs.php file under Listeners with:
Code:
<?php  class Biblioteca_Listeners_Tabs
{
     public static function navtabs(array &$extraTabs, $selectedTabId)
     {
         $extraTabs['biblioteca'] = array(
             'title' => new XenForo_Phrase('Biblioteca'),
             'href'  =>  XenForo_Link::buildPublicLink('pages/biblioteca'),
             'selected'  =>  ($selectedTabId == 'biblioteca'),
             'linksTemplate' =>  'Biblioteca_Navtabs',
             'position' => 'middle'
         );
     }
 }

Then under the admincp>Development>Code Event Listeners, I created a new one like this:
event.webp

The tab is there, but is not selected:
tab.webp
 
You don't need an "selected" index anymore, the framework is doing the work for you.

What's your route code?
There you need to set the "major section" (the selected tab;) )

For example:
return $router->getRouteMatch('Ragtek_InfoPage_ControllerPublic_Info', 'index', 'info');

sets 'info' to be selected
 
You don't need an "selected" index anymore, the framework is doing the work for you.

What's your route code?
There you need to set the "major section" (the selected tab;) )

For example:
return $router->getRouteMatch('Ragtek_InfoPage_ControllerPublic_Info', 'index', 'info');

sets 'info' to be selected

I need a route? lol did not even know, about that, must have tottaly missed it some how.

So I'm assuming I should be a Route>Prefix folder under Biblioteca, what's the code that goes in there other then what you mentioned above?
 
Oh sorry, haven't seen that you're linking to pages.
I thought you're having an own controller

Moment, have to check this:D
 
Oh sorry, haven't seen that you're linking to pages.
I thought you're having an own controller

Moment, have to check this:D

Thanks, would it be easier to have an own controller or is that only necessary if your building your own plugin with you own .php files, etc..?
 
Sorry, i don't know if it's possible.

The problem is, that the pages route have already defined "forums" as the section

PHP:
return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', 'forums');
Maybe somebody else knows if it's possible, i don't have the time to check this, sorry.
 
Thanks, would it be easier to have an own controller or is that only necessary if your building your own plugin with you own .php files, etc..?
For me as a coder, it's easier.
I use own controllers & routes for everything, just because of this problems(and because it's IMHO easier)^^
With own controllers & routes, i can have define own entries for the "current visitors" etc..
 
ragtek, I found this: http://xenforo.com/community/threads/assign-pages-to-different-tabs.7006/

The only downside to that is, if you have some pages already created, you'll have to change the url with a suffix to it :/

Thanks for your help!

Yeah, but if you know some PHP, it wouldn't be tough to modify that to work on an arbitrary page. ;)

I made this suggestion in another thread...haven't tried it (maybe I should before I go shooting my mouth off!), but if you don't need the page to display in the node tree, you can create your own route/route prefix that points to the page controller. So, something like http://www.yourdomain.com/bibleoteca, which would allow you to control the selected tab.
 
Yeah, but if you know some PHP, it wouldn't be tough to modify that to work on an arbitrary page. ;)

I'll look into the above addon to see if I can figure something out with that!

I made this suggestion in another thread...haven't tried it (maybe I should before I go shooting my mouth off!), but if you don't need the page to display in the node tree, you can create your own route/route prefix that points to the page controller. So, something like http://www.yourdomain.com/bibleoteca, which would allow you to control the selected tab.

I don't need it to appear in the forum list, how can I build a route prefix pointing to the url as you mentioned? Or do you know of any thread here that can shed a light?
 
Is it possible to exclude the button from appearing on certain pages? If so how?

I sure it's possible, with something similar to THIS_SCRIPT(VB), they call it something else here on Xen, I seen Kier talking about it in a thread before, but not sure where that thread is right now.

EDITED: Actually the thread is: http://xenforo.com/community/thread...ion-this_script-index.6664/page-2#post-170931

Code:
<xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Page' AND {$controllerAction} == 'PAGE_NAME'"><!-- your stuff here --></xen:if>

I haven't tested the above code yet, but I assume it would work. although for this plugin I think you would have to be implemented in the controler public some how.

Is there any more positions possible yet other than
middle end home ?

Thanks

Not that I know.. I was actually wondering about this too. Maybe Brogan or someone else can help us out.
 
middle=>after the forums tab +1 to move it up one this would be great

looks like most addon authors are making their navigation_tabs listeners fire at (Callback Execution Order = 10) ... you can edit each navigation_tab and set the callback execution order for those "middle" tabs to be in a specific order just by changing that value. ie, if you have 4 addons that have tabs in the middle and they are all set to 10, leave the one you want first at 10, then make the next 11, then 12, then 13 and so on..
 
looks like most addon authors are making their navigation_tabs listeners fire at (Callback Execution Order = 10) ... you can edit each navigation_tab and set the callback execution order for those "middle" tabs to be in a specific order just by changing that value. ie, if you have 4 addons that have tabs in the middle and they are all set to 10, leave the one you want first at 10, then make the next 11, then 12, then 13 and so on..
Thanks man got an example of a Callback Execution Order in the php code?
 
Thanks man got an example of a Callback Execution Order in the php code?

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.

Click on the navigation_tabs listener that you want to edit, set the Callback Execution Order field (which will most likely be set at 10) to 11 or 12 or 13 or 14

Do this for each navigation_tabs listener that use the middle (that you want to change the order on).

if you have 4 middle tabs, set the first one you want in order to 10, then the 2nd one to 11 and the 3rd one to 12 and the 4th one to 13 ... they will then display in the order you want.

NOTE: Please use this very sparingly and not as a "Solution"
 
Back
Top Bottom