Highlighting current page tab in navigation bar
Let your readers know where they are on your blog. How? By highlighting the tab of the page they are currently viewing. See the demo on my widget showcase blog.
We can detect the current page by using conditional if tag in the navigation bar HTML code. Normally we would have to use one set of conditional if tags for each link/tab.
But if your navigation tabs is made of a LinkList gadget, you can reduce the tags to just one set. Here’s how:
(Note: If you use a PageList gadget as a navigation bar, you can skip steps 2 and 3. The gadget already has a built-in current page detection code).
1. Finding the navigation bar LinkList code
- Find the navigation bar’s widget Id (hint: the Id starts with “LinkList”, followed by a number). For the sake of this tutorial we will address the Id as YourWidgetId.
- Go to Dashboard > Layout > Edit HTML.
- Back up your template.
- Tick the Expand Widget Templates check box on top right of the HTML window.
- Look for the navigation bar LinkList code by searching for the widget id you identified in step 1 (Use Ctrl+F). The code should look something like this:
<b:widget id='YourWidgetId' locked='false' title='' type='LinkList'> <b:includable id='main'> <b:if cond='data:title'><h2><data:title/></h2></b:if> <div class='widget-content'> <ul> <b:loop values='data:links' var='link'> <li><a expr:href='data:link.target'><data:link.name/></a></li> </b:loop> </ul>
2. Modifying LinkList code
- Replace code line 7 with this code:
<b:if cond='data:blog.url==data:link.target'> <li class='selected'><a expr:href='data:link.target'><data:link.name/></a></li> <b:else/> <li><a expr:href='data:link.target'><data:link.name/></a></li> </b:if>
- The final code will look like this:
<b:widget id='YourWidgetId' locked='false' title='' type='LinkList'> <b:includable id='main'> <b:if cond='data:title'><h2><data:title/></h2></b:if> <div class='widget-content'> <ul> <b:loop values='data:links' var='link'> <b:if cond='data:blog.url==data:link.target'> <li class='selected'><a expr:href='data:link.target'><data:link.name/></a></li> <b:else/> <li><a expr:href='data:link.target'><data:link.name/></a></li> </b:if> </b:loop> </ul>
3. Highlighting the tab
To style the tab, you simply add a styling rule in CSS, like this:#YourWidgetId .selected {
background-color: #fff;
border-bottom: none;
/* add more styling declarations here */
}
And place it before ]]></b:skin> line in your template code.
Enjoy!


This is the url:






























