Tuesday, August 4, 2009

How to show Profile widget only at Home Page of Blog

Go to your blog's Layout Page, and enter HTML-edit mode. Download your template as an XML-file and store it in a safe place. In case template-hacking takes a wrong turn somewhere, you can upload your template-file again and you are back to normal.

Now click on Expand Widget Template

Step 1: Then Find the Profile Widget
Expand the widget-code by checking the checkbox on the HTML-edit page. Now scroll down and look for the Profile Widget, that looks like this:

<b:widget id='Profile1' locked='false' title='About Me' type='Profile'>
<b:includable id='main'>
<b:if cond='data:title != &quot;&quot;'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
</div>
</b:includable>
</b:widget>

Step 2: Modify the widget code
Now we only want to display this widget if the page that we are looking at is our blog's Homepage. We will use a <b:if>-statement to check for this situation.
Insert the following (red) lines of code into the widget code:
<b:widget id='Profile1' locked='false' title='About Me' type='Profile'>
<b:includable id='main'>
<b:if cond='data:blog.homepageUrl == data:blog.url'>
<b:if cond='data:title != &quot;&quot;'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
</div>
</b:if>
</b:includable>
</b:widget>

The datafield data:blog.homepageUrl contains the url of your blog's homepage.
The datafield data:blog.url holds the url of the current page.
If they are the same (==) we are on the homepage and the widget should be displayed.
If they are not the same, the widgetcode is skipped.

Step 3: Save your template
Save your template and display your blog.

So how did you like the article? Then don't wait and Subscribe, Rss, Explore and Comments on My Blog. Thanks for visiting and be a frequent visitor.  




0 comments:

Post a Comment

 

About Me

My photo
Hey guys this is Vaseem Ansari, 25 years old, Software & Web Developer, Blogger & works on Open Sources Technologies I love my family and my loved once very much. It takes a while for me to build trust in someone new. I am honest, thoughtful, and my friends tell me that I am wise. I would also say that I am stubborn. but I do learn from my mistakes. I'm Glad I'm Me No one looks The way I do. I have noticed That it's true. No one walks the way I walk. No one talks the way I talk. I am me. There's no one else I'd rather be! Have fun reading this blog and don't forget to subscribe to the feed to keep updated on the latest articles. Visit my Blog at http://www.VaseemAnsari.com/blog/

Followers