$extratabs -> Is there a way to force the order here?

SchmitzIT

Well-known member
Most add-ons that add their own navtab do so by extending the $extratabs variable. You can choose a position (begin, middle, end) there, but is there an option to determine in which order the tabs are going to be displayed?

I saw @Jake Bunce 's "Nodes as Tabs" has such an option, but haven't been able to find the code that handles it (other than just setting the order in which they are retrieved from the database).

We use Nodes as Tabs at my customer's forum, and basicaly want to ensure a specific tab ends up after the ones added by Nodes as Tabs. I tried using the Code Event Listener execution order, but that seems to have no effect, so I'm hoping there's some kind of a programmatic way of setting the order.

Thanks!
 
Unless Nodes As Tabs overwrites some sort of functionality that orders tabs, then changing the navigation tab execution order should sort it out.

So as you've already recognised, there's three positions: home, middle, end.

Changing the execution order will only affect its order within that position. By that I mean... If you have:

Tab1: Home
Tab2: Middle
Tab3: Middle
Tab4: End

If you changed the execution order of Tab2 so it executes last, all that will do is change the order to:

Tab1: Home
Tab3: Middle
Tab2: Middle
Tab4: End

What you need to do is change Tab2 to the End position AND change its execution order (so it executes last) and the end result should be:

Tab1: Home
Tab3: Middle
Tab4: End
Tab2: End

All add-ons will use the navigation_tabs code event listener to add additional tabs. Most of the time that will be in a file called Listener.php. But it varies from developer to developer. The code event listener in the Admin CP will help you locate the file the code is located in.

Once you've found that, change the position in the code to "end". And once you've set the execution order you should now be able to move your tab.

The only way this wouldn't work is if a developer has added a navigation tab directly to the template... That's not at all recommended but I think I once saw someone do that.
 
I saw @Jake Bunce 's "Nodes as Tabs" has such an option, but haven't been able to find the code that handles it (other than just setting the order in which they are retrieved from the database).

NodesAsTabs has a display order for each node tab which controls the order of node tabs amongst themselves within each position.

In addition, NodesAsTabs has what is likely to be a unique feature:

Admin CP -> Home -> Nodes As Tabs -> Force Order - * Position

This option is made possible because I have set an extremely high execution order for the listener to ensure that my addon runs last. That allows me to add on to the beginning or end of the extraTabs array knowing that no one is running after me. It's basically a power play with the execution order. Only the highest execution order can exercise this kind of control. This is really only appropriate for a generic navigation addon like NodesAsTabs. Other addons with only one tab are unlikely to do this as it really wouldn't be appropriate.

We use Nodes as Tabs at my customer's forum, and basicaly want to ensure a specific tab ends up after the ones added by Nodes as Tabs.

Use the option I just posted:

Admin CP -> Home -> Nodes As Tabs -> Force Order - * Position
 
This option is made possible because I have set an extremely high execution order for the listener to ensure that my addon runs last.
...
Use the option I just posted:

Admin CP -> Home -> Nodes As Tabs -> Force Order - * Position


That explains a lot (The high execution order, that is). I set the add-ons tab to 90, which simply might not be high enough.

The add-on in question just creates a tab, not a sort order. Could you share what execution order you added? If I can get mine in to be higher, my issue would be resolved. I actually pondered adding an additional hook in the template right before the member tab to allow me to get the tab positioned where it's wanted, but if I know the proper number to "override", that'd work as well :)
 
That explains a lot (The high execution order, that is). I set the add-ons tab to 90, which simply might not be high enough.

The add-on in question just creates a tab, not a sort order. Could you share what execution order you added? If I can get mine in to be higher, my issue would be resolved. I actually pondered adding an additional hook in the template right before the member tab to allow me to get the tab positioned where it's wanted, but if I know the proper number to "override", that'd work as well :)

2.1 billion is the execution order I used.

If your goal is to change the position of your tab with respect to a node tab then you don't need to change any execution orders or edit any templates. The configurable option in NodesAsTabs will take care of it for you. Set an order of "first" if you want the node tab to be before other tabs in that position. Or use "last" (the default) to have the node tabs come after other tabs in that position.

Admin CP -> Home -> Nodes As Tabs -> Force Order - * Position

Based on your first post, you want to set this to "first".

I do not recommend changing your addon to have a higher execution order than mine. It would break the "Force Order" options that already exist in my addon which are there to save you from having to edit execution orders in the first place. To use a higher execution order than NodesAsTabs is to take that control away from NodesAsTabs which is only appropriate if your addon represents more tabs than NodesAsTabs, and it is not necessary to resolve your current conflict as NodesAsTabs already provides the option.
 
Thanks, Jake. I must have mis-read earlier. I was looking at the settings in the individual nodes themselves.

Thanks again!
 
Top Bottom