July 12, 2011

Use Blogger Page links as label filter

In blogger, when user desires to add the link of posts specific to label in the page navigation.
Use the below code in the page html, enclosed with the script tag.

Change the URL as per requirements. Whenever user clicks on the page link it will redirect to the specific label filter page specified in the script. It also handles mobile layouts too.



function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
if(getQuerystring('m'))
window.location="http://www.YourBlog.com/search/label/DESIREDLABEL/?m=1";
else
window.location="http://www.YourBlog.com/search/label/DESIREDLABEL";

2 comments: