Stubborn Fanatic

Avatar

Documenting Tech Fanaticism


You're browsing: Home » blogger, blogging, my hacks » Blog article: Displaying widgets only on comment, label, search and archive pages

Displaying widgets only on comment, label, search and archive pages


Hello Friends,

From certain site tracking services, I have been looking at the way people come to know about my blog and I realized that only few of them access my blog directly (using its main URL). Most of them come looking for some hack (like social bookmarking, Google Translate etc) and land on an individual post page. When they land on such a page, a lot of space under the article + comments section goes waste as my blog’s sidebars (in most cases) are longer than the length of the post + comments section. This is also the case on label, archive and search pages. I was wondering how to make efficient utilization of this wasted space so that such first time readers (of my blog) get enough information about my other posts and I am able to convert them to returning readers/visitors.

I turned to instabloke for ideas and found that Blogbloke has made very good use of this space by posting a list of other articles, newsfeeds of his blog and adsense code. Inspired by his ingenuity, I decided to implement the same for blogger beta. To understand what I am talking about have a look at these pictures:

1. Bottom of the “main” section on my blog’s main page:


2. Bottom of the “main” section on a label page:


3. Bottom of the “main” section on a individual post/comments page:


You will notice that certain sections that do not appear on my blog’s main page appear on the label, archive, post/comments and search pages (I refer to them as “non-main” pages). See this image below. The highlighted widgets in the following image do not appear on the main page but appear on all other pages (i.e. non-main pages):


Here’s how you can also make a widget to appear on all other pages except the main blog page.

1. Add a page element


First add a page element (widget) of your choice from you blog’s page element (Edit Layout) section. Don’t forget to give it a unique title as it becomes easier to search for the widget in the template code.

2.View template code


Then go to the Edit HTML section of your blog and view the expanded widgets template code. (Please make a backup copy of your template before you proceed)

3. Search for the newly added widget/page element


Now in template code search for the widget you just added using its title.

4. Modify the Widget code

Modify the code as shown below by adding the “if” condition (in bold). Make sure you add the “if” condition just after the <b:includable id=’main’ section> and the closing “if” code just before the </b:includable>.

<b:widget id=’AdSense1′ locked=’false’ title=” type=’AdSense’>
<b:includable id=’main’>
<b:if cond=’data:blog.homepageUrl != data:blog.url’>
<div class=’widget-content’>
<data:adCode/>
</div>
</b:if>
</b:includable>
</b:widget>

5. Now save the template and you are done.

A special mention here for an Ajax-based hack by Hoctro which I used to display a large number of posts on my blog’s “non-main” pages. I did not use the feed widget for this purpose as Blogger limits the list to a max of five posts.

So go ahead and fill up those spaces and feel free to drop a line if you face any issues.

Update-01: To learn how to display widgets only on the blog’s main page click here.

Update-02: To learn how to display a widget only on a particular label page or any other URL (from the same blog), click here.


No related posts.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
PDF version
  • Plaxebo
    this hack does not show content on blog but it keeps space for content. How i could also hide this space on blog from main page?
  • topi jrami
    hi vivek, can we make certain widgets display only on the search result...

    thx in advance
  • topi jrami
    hi vivek, how can i show a widget in search result page only...? can i do that...?

    thx
  • Vivek Sanghi
    @The Blissful Glutton
    Hello there. I checked the link you posted at the end of your message and checked your blog's main and post pages. However I could not find the problem you have mentioned. Could you send me the link of a specific post page where you are facing this problem such that I can replicate it at my end and provide a solution.
  • The Blissful Glutton
    Why can't I get this to work? i am trying to put widgets on main page only because they are screwing up my posts pages. Help please! www.blissfulglutton.com
  • PTHEGROUP®
    I 0wn this blog called www.orkuttricks.blogspot.com
    I wanted to put up a text widget called "Welcome to orkut tricks"(title) with some info about the site in it.I wanted this to be visible only on the homepage.

    I tried as what was said but still this widget is visible on all pages & not only on home

    [b:includable id='main'][b:if cond='data:blog.homepageUrl == data:blog.url'][/b:if][div class='widget-content'][data:content/][/div]


    plzzzzzzzzzzzzzzzzz help
  • MrBrownThumb
    Hey,

    This hack works great for the adsense widget but can it be used for labels showing only on post pages and not the main page?

    The labels widget already has conditionals like (/b:if) and trying to add the code and conditional you gave in the adsense example just gives error codes. I've read the comments but I'm not sure if one of those applies to the labels widget.
  • Andrej
    Hi,
    I would like my main page to display only post with a certain label and a link to recent post (of any label). How could I do that?
    Thanks.
  • Escaper
    Thanks all of your help Vivek, i have done it and it works great;)
  • Vivek Sanghi
    Hello Escaper. Try the following if condition.

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

    </b:if>
blog comments powered by Disqus