A Technology blog that provides tips on Android, iPhone, Social media, Ubuntu and other web product and services.

How to add Star-rating to Custom Blogger Templates

Blogger in draft recently launched couple of updates, fixes and two most sought features to Blogger in draft:

  • Embedding Comment form in each post.
  • Adding Star rating to individual posts.

To read about the complete list of updates and fixes, read this post on Blogger in draft blog.

Now to embed comment form for custom blogger themes and modified templates, Amanda on Blogger Buster has written an excellent how to.
To add Star rating to these kind of custom theme enabled blogs, I couldn’t find any trick.  But I sort of played with the code and came up with a solution which should work with any custom built blogger template.

Step 1: Backup your existing template.  I assume you know it very well so I am not gonna explain it again.
Step 2: Expand widget templates and copy the entire code some where in Notepad or something.  In case something goes wrong, you have the entire widget code.
*Step 3: Go to ‘Layouts’ and under ‘Blog post’ widget, select Star rating.  And save the changes.

*Step 4: Go to ‘Edit HTML’ and select ‘Expand widget templates’.
Step 5: Search for this line of code:

<p><data:post.body/></p>

Step 6: Copy the following code right after the above line of code:

<span class=’star-ratings’>
<b:if cond=’data:top.showStars’>
<div expr:g:background-color=’data:backgroundColor’ expr:g:text-color=’data:textColor’ expr:g:url=’data:post.absoluteUrl’ g:height=’42′ g:type=’RatingPanel’ g:width=’180′/>
</b:if>
</span>

Step 7: Now again search for following code:

<b:include name=’feedLinks’/>

This line you may find several times, so make sure you seek for the last instance at the bottom of the code which should ideally be before the start of sidebar codes.  So when you see this line, it should look something like:

<b:include name=’feedLinks’/>
</div>
</div>
<div class=’cont-bottom’/>
</div>
</div>
</div>
</b:includable>
</b:widget>
</b:section>
….
….
<div id=’sidebars’>

Step 8: Copy the following code right after the line mentioned above:

<b:if cond=’data:top.showStars’>
<script src=’http://www.google.com/jsapi’ type=’text/javascript’/>
<script type=’text/javascript’>
google.load(&quot;annotations&quot;, &quot;1&quot;);
function initialize() {
google.annotations.setApplicationId(<data:top.blogspotReviews/>);
google.annotations.createAll();
google.annotations.fetch();
}
google.setOnLoadCallback(initialize);
</script>
</b:if>

Step 9: Preview your changes without saving it.  You should see the star rating in each post on your blog posts on the main page itself.
Step 10: That’s it, save your template if satisfied and enjoy the Star ratings on your blog.

Also let me know if this post helped you in customizing your template by dropping a comment here or at least leaving your rating.

*Update :  Added Steps 3 & 4.  Added image for clarity.

Related Posts

View Comments to “How to add Star-rating to Custom Blogger Templates”

  1. Anurag Bansal says:

    @Brad Farless:
    I checked your blog and it seems you are showing the blog rating in the bottom footer of every post.
    Wouldn’t it be good to show in line with the ‘Bookmark’ widget? You wouldn’t have to worry about background color.
    Else you need to check the color of your footer. If you want you can send me the full template of your blog. I can look and let you know where you need to change, what.

    Hope it helps.

    Cheers
    Anurag Bansal

  2. Brad Farless says:

    How would I do that? Have them show up next to each other? Or rather, one on top of the other, centered would be nice. I tried, but the stars seem a little skewed to the left. I’ll send you my template so you can take a look.

  3. Brad Farless says:

    Or you could tell me how to change the background color in that footer section?

  4. Anurag Bansal says:

    @Brad:
    I sent you the updated template. Check if it works the way you wanted.

    Thanks
    Anurag Bansal

  5. Gerard Banhidi says:

    Hi Anurag,

    I simply cannot enable posting comments in my Blog. Could you please edit my template?

    I will send you an e-mail.

    Thanks in advance.

  6. Mohit says:

    Hi Anurag!

    Could you help me to change the white background color of Star Rating System. The white background doesn’t match with the theme. My blog address is http://testingnook.blogspot.com

    Thanks in Advance.

  7. Anurag Bansal says:

    @Mohit:
    Currently there is no way of matching ‘Star Rating’ Background with the template. It indeed, looks ugly on a dark background blog.
    Sorry, I can’t help with that.
    Instead if you want, you can try a Google Friend Connect widget for ratings. That seems to work well. Let me know if you need help with that.

    Cheers
    Anurag Bansal

  8. Mohit says:

    Thanks anurag for your help and time :) I think I should remove the ratings for now…I will add it in future when I have followers for my blog :)

  9. my_passion48@yahoo.com says:

    hi anurag please help its not working for me. i am sending my XML template to you on blog@knowliz.com please check it if there any problem.

    Regards
    inder

  10. TODO http://bit.ly/Zsvp0
    blog star rating flash2nd

  11. Floweringarden says:

    How do I add star ratings to my blog if my blog edit does not have the box to select star ratings? Thanks for your help

  12. Are you using Blogger? Try switching to draft.blogger.com and then check, you should see “Star Rating” in your blog template layout dashboard.
    I will suggest reading the article again to understand all steps.
    Thanks

  13. Floweringarden says:

    Thank you very much for your help but now it displays twice? Your advice is greatly appreciated.

  14. That's good.
    And the problem you are talking about is pretty common and very simple
    to rectify. Just search for the Star rating code block. It must be
    twice in your template.
    Delete one set. Preview before saving. If everything is fine, then
    save your template.
    That's it. Enjoy.

    Anurag Bansal

  15. Floweringarden says:

    Dear Anurag:

    Now the star ratings is working very well but when trying to click on post a
    comment, it does not allow me to do it. Any ideas? Thanks very much.

    Floweringarden.

  16. Try reverting the changes to see if it was because of Star rating. If it is then you will have to go through the tutorial again to see if you missed something, pasted the code at wrong place or something like that.
    Else you know it is not because of Star rating modification, so the cause should be something else. That you will have to find yourself. May be you did some recent changes, some javascript or something. (Hint)
    Let me know how it goes.
    Thanks

  17. Isa says:

    Hi, I am trying to add a “Star rating” option to my blog. However , when I try to do Step 3 (*Step 3: Go to ‘Layouts’ and under ‘Blog post’ widget, select Star rating. And save the changes.), I dont see this option of Star rating. Any help will be greatly appreciated. Thanks!

  18. Isa says:

    Please ignore my earlier question. Figured it out, it works now. Thanks for the explanation on your post.

  19. vyacheslavtrotsak says:

    You have been only who resolve my problem since I have read many materials!

    But how make that it is appeared in Russian language?

  20. levi22 says:

    hi can you help me with my white background star rating. it doesn't blend on my template.. i just have a black background.. can u just give me the code and guide me to where i will paste it? Please email me. Thanks!

  21. dhm says:

    worked like a charm … I added it just below the title – it takes time to load and appear but finally does. That's the only thing that took me 20 minutes to figure out :(

  22. dhm says:

    worked like a charm … I added it just below the title – it takes time to load and appear but finally does. That's the only thing that took me 20 minutes to figure out :(

Leave a Reply





blog comments powered by Disqus