XF 2.1 Top Navigation Tabs - is selected

TheSkullKid

Active member
How can I add a new tab to the navigation bar, so that the IS-SELECTED will be used?
I can add a new public navigation with the type:
  • Basic
  • Node
  • Callback
If i use BASIC and and enter a Link, how can this tab be marked as selected?
I want to add e.q. Current Visitors as a tab, and used "{{ link('members/&key=most_points') }}"
Do I need to use one of the node types instead to do that?
  • Category
  • Link forum
  • Page
  • Forum
  • Node Layout separator
Thanks for the help
 
Assuming you want the tab to only be highlighted for most points and the default Members tab to be highlighted at other times, you would need to edit the member_notable template and add this after the first <xf:title> line:
HTML:
<xf:if is="$xf.uri == {{ link('members/?key=most_points') }}">
    <xf:page option="section">navID</xf:page>
</xf:if>

Replacing navID with the actual ID of your nav tab.

You have a typo here:
{{ link('members/&key=most_points') }}"

It's a ? not an &.
 
Thanks, this is much appreciated, but it is not working.
The members/&key=most_points was just an example, it could be anything else.

I add a navigation route called MemMost and used basic and add the link into the link field as mentioned above. If I know click on the new created navigation tab the page :Most points" will be opened but the tab is still not selected, it is still the members tab which is marked as selected.

I will check again and do some deeper look into the templates, but what happened if this will be link outside the forum or anything in the user profile?
 
but what happened if this will be link outside the forum
If the link is not part of XF then naturally the tab won't be highlighted.
How could it be - the user is either viewing a different tab, or the page has changed to the new link.

I also edited the code - there was a slight typo in it.
I can confirm it works.
 
If I change & to ? it do not do anything, and you still remain or reach the main page of the forum.

All links I want to add to the top of the navigation are inside the forum, like specific account information, like profile, or specific member information, like most points.
 
You're not using friendly URLs so use this instead for the conditional statement (it's a more valid approach anyway):

HTML:
<xf:if is="$xf.uri == link('members', null, {'key': 'most_points'})">
    <xf:page option="section">mostPoints</xf:page>
</xf:if>
 
Back
Top Bottom