Friday, 30 September 2011

Blogger Widget Hacks: Customizing Blogger Widgets To Appear Only On Selected Pages

Wordpress enjoys much more flexibility and features than Blogger and its very easy to show & hide widgets in Wordpress.Unfortunately in Blogger the sidebar widgets are interwined in an intricate web,altering which may result in display errors or template issues there by rendering your blog helpless.Thankfully there is an alternative fix for this scenario which involves a little tweaking of your blogger template.I will be dealing with three different scenario's which are applicable and implement the one applicable to you.The procedure is same for all three scenario.


 Step1) Go to Blogger>>>Design>>Edit Html>>>Download your Template & save it in your hard-disk.Always make sure you make a copy of your template to revert the changes.

Step2) Now in Edit Html>>>Click on Expand Widgets & Search for the Following Piece of Code:
<b:widget id='HTML
Or Something Like This:

<b:widget id='HTML1' locked='false' title='The title/name you gave to your widget' type='HTML'>
The number in Red depends upon the number of widgets which you have enabled.

Step3) Now Depending upon the following Scenario,add the codes displayed in Red

For Displaying Widgets Only in the Home/Main Page:

<b:widget id='HTML5' locked='false' title='Widget Title Name' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>
<b:include name='quickedit'/>
</b:if> </b:includable>
</b:widget>
 To Display Widgets On all pages Except the Home/Main page:

<b:widget id='HTML3' locked='false' title='Widget Title Name' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "item"'> <!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>


<b:include name='quickedit'/>
</b:if> </b:includable>
</b:widget>
To Display Only on Archived Pages:
<b:widget id='HTML3' locked='false' title='Widget Title Name' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "archive"'> <!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>

<b:include name='quickedit'/>
</b:if> </b:includable>
</b:widget>
That does it. And oh incase you run into any issues during the installation process, feel free to ping me and I'll get back at the earliest.

No comments:

Post a Comment