Monday, October 10, 2011

Blogger Label Specific Gadget


I can't think of a better title for this post. This is what the tutorial does. Say you have a gadget, and you want the gadget to be displayed only on post pages that have a particular label. The gadget won't be shown in any other pages- this includes your homepage, static pages and other post pages that don't have the said label. This question was asked by blog reader Ranjan. Sorry for the delay buddy.

Step 1:

Go to Dashboard - Layout - Add a Gadget - and add the gadget like you normally would.


Step 2:

Identify the gadget's unique ID. Click here to learn how you can identify your gadget's ID. For the sake of this tutorial, I'm going to be using the gadget ID #Text1.


Step 3:

Go to Dashboard - Template - Edit HTML - Expand Widget Templates - Find for </b:skin> - Paste the following code directly below </b:skin>:
<b:if cond='data:blog.url != &quot;http://yoboy-testblog7.blogspot.com/search/label/texthide&quot;'>
<style>
#Text1{
display: none;
}
</style>
</b:if>
Replace the address in Line 1 in the code above with the address of your label page. You can get the address of your label page by clicking on your label. It goes without saying that this is the label that you will be using to 'show' your gadget. I'll be using the label 'texthide' because I haven't had my coffee and I can't think of anything smart right now.

Also, replace the ID in Line 3 above with the ID of your gadget.


Step 4:

Find for <b:loop values='data:post.labels' var='label'> - paste the following lines directly below it:
<b:if cond='data:blog.pageType != &quot;index&quot;'>
<b:if cond='data:label.name == &quot;texthide&quot;'>
<style>
#Text1{
display: block !important;
}
</style>
</b:if>
</b:if>
In Line 2, replace 'texthide' with the name of your label. And don't forget to change the Gadget ID in Line 4 above with that of yours.


My apologies if you find the tutorial messy. I tried hard not to bring Javascript in. So yeap, the tweak above is completely HTML-based. And I haven't really had the time to check for bugs thoroughly. Let me know if you find any.

Elm0D

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment

Navigate» Become author for this Blog

Manual Categories