How to display chosen gadgets only on Blogger blog post pages

You may want some individual gadgets to appear on a post page and not in the home page or labels page of your blog. For example, you would like your ad to appear only inside the content of the article when a post page is visited. This article will describe how to show relevant gadgets on Blogger blog post pages.

Step 1: Sign in to your blog
Visit Google Blogspot home page at: http://blogspot.com/ or http://www.blogger.com/ and sign in with your Google account.

Step 2: Locate the id of your chosen gadget
When you sign in to your blog, you are presented with the main dashboard. You can then click 'Design' link under your chosen blog title.

Under 'Page Elements' tab, click 'Edit' link of your Blogger gadgets'. In the title text box copy it's title.

You can then click 'Edit HTML'. Tick the 'Expand Widget Templates'. Search for the title of your gadget.

By doing this you can know the id selector of your gadget. Your gadget code may look like the following:

<b:widget id='your_gadget_id' locked='false' title='your_gadet_lable' type='your_gadget_type'>
<b:includable id='main'>
  <b:if cond='data:title'>
    <h2><data:title/></h2>
  </b:if>
    ......
</b:includable>
</b:widget>

Step 3: Add condition for displaying the gadget on post pages
Add the conditional tag <b:if cond='data:blog.pageType == &quot;item&quot;'> to make your gadget appears only on the post pages. This tag should  be added below<b:includable id='main'>. Then add the closing </b:if> tag above </b:includable>.

Your modified gadget code may look like the following:

<b:includable id='main'>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
  <b:if cond='data:title'>
    <h2><data:title/></h2>
  </b:if>
    ......
</b:if>
</b:includable>

No comments:

Post a Comment

Blog Archive

About Me

My photo
I am a software developer with roughly 5 years of experience in developing end-to-end solutions in C#, Java, C/C++, PHP and HTML/CSS/Javascript. At the moment, I am joining the Professional Doctorate in Engineering degree program in Software Technology at Eindhoven University of Technology. My areas of particular interest include software design, data structures and algorithms, problem solving, software security, embedded system, machine learning, and data science.