Saturday 7 February 2015

Add links to a pages based menu on Blogger

The pages widget on Blogger is very useful for use as menu, however, it has a weakness: you can’t add links directly from the panel, but this is possible from the code.
Step by step:

1. Go to your template code (Desktop → Design → Edit HTML) and expand widget templates.

2. Search the pages widget code, it looks more or less as follows:

<b:widget id='PageList1' locked='true' title='Pages' type='PageList'> <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:link.isCurrentPage'> <li class='selected'><a expr:href='data:link.href'><data:link.title/></a></li> <b:else/> <li><a expr:href='data:link.href'><data:link.title/></a></li> </b:if> </b:loop> </ul> <b:include name='quickedit'/> </div> </b:includable>
To facilitate the search, can search with your browser: id = ‘PageList
3. Once you locate the code, there are two places where you can put new links:
  • Before <ul>. The link will be the first one in the menu.
  • After </ul>. The link will be the last one in the menu.
As this is an HTML list, the link will follow this format:

<li><a href='http://mysite.com/mylink/'>My link</a></li>

You can add as many links as the design permits. Always taking care of opening and closing tags correctly.
4. Save the changes.

In this way you can add links to a important label, an external site, the feed url or any other link.

0 comments:

Post a Comment

 
Sohoz-Tech