Display Specific Widget/Element on Specific Pages

Posted by: Shahbaz Malik on 6 February 2012 Under:
display widget on specific page
Blogger provide a large number of widgets to the readers. If you are interested to show specific widgets on specific pages of the Blog then you can easily do it by making a small modification in Blogger Template. When you use large number of widgets on the page that will slow down your Blog loading time due to this I am sharing this tutorial to avoid that problem.

How many types of Pages in Blogger:-

Generally Blogger provide seven type of page type to the readers but here we will discuss only the important one for you.
  • Item page:- The individual Post Pages of the Blog are called Item page. eg. http://internetricks4u.blogspot.in/2012/02/remove-home-newer-post-and-older-post.html the page, link to this url is Item Page.
  • Index Page:- The Home Page of the Blog is called index page.
  • Archive Page:-It is the Archive page of the Blog. eg.http://internetricks4u.blogspot.in/search?updated-min=2011-01-01T00:00:00%2B05:30&updated-max=2012-01-01T00:00:00%2B05:30&max-results=50 Page link to this url is Archive Page.
  • Static Page:-Stand-alone pages of the blog are called Static Page, Contact Me, About us pages are of this type. 

How to Display specific widget:-

As you can see from the following I add blinking pink part in this code to display it on index page.

<b:widget id='HTML3' locked='True' title=' Any Gadget Name ' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == 'index"'>


<b:if cond='data:title != ""'>
<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>

If you apply this code in template then this widget will only display on the index page or you can also use
  • <b:if cond='data:blog.pageType == "item"'>.........</b:if> to display this widget only on the Post Pages.
  • <b:if cond='data:blog.pageType == "static_page"'>.........</b:if> to display only on the Static Pages.
  •  <b:if cond='data:blog.pageType == "archive"'>.........</b:if> to display widget only on archive pages.
lets's take another example -

<b:includable id='postQuickEdit' var='post'>
  
<b:if cond='data:post.editUrl'>
    
   <span expr:class='&quot;item-control &quot; + data:post.adminClass'>
      <a expr:href='data:post.editUrl' expr:title='data:top.editPostMsg'>
        <img alt='' class='icon-action' height='18' src='http://img2.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/>
      </a>
    </span> 

 </b:if>

</b:includable>
If you want to show this element only Post Pages then make the following changes in it.

<b:includable id='postQuickEdit' var='post'>

 <b:if cond='data:blog.pageType =='item''>

<b:if cond='data:post.editUrl'>
    
   <span expr:class='&quot;item-control &quot; + data:post.adminClass'>
      <a expr:href='data:post.editUrl' expr:title='data:top.editPostMsg'>
        <img alt='' class='icon-action' height='18' src='http://img2.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/>
      </a>
    </span> 

 </b:if>


  </b:if>

</b:includable>
I give my best to produce this article but if any one find any difficulty then comments are always open for that.
If you enjoyed this article then kindly take 5 seconds to share it!!

0 comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...