Monday, October 6, 2014

How To Modify Blogger Popular Posts For Gallery Template

Today I will try to discuss a feature that commonly provided in the current Blogger template, which is Popular Post / Most Viewed Post. This feature is provided by default in Blogger, just go to your Layout are to find it by adding a new Widget / Gadget.

Popular Posts is a list containing the posts that are getting the most views among other posts published on your Blogspot blog, so they deserve to appear on Popular Post section. You can limit the number of posts according your own wish.

In Blogger, this feature appears interesting without modification. You will be given number of options like how many post should appear, thumbnail and descriptions / summary.

If your blog is gallery type blog, then you will likely to have thumbnail only than having summary + thumbnail. Here is the example of what I am talking about.

How To Modify Blogger Popular Posts For Gallery Template

And now I will try to modify the Popular Post widget to be matched if installed on the gallery content blog. The result of the modification is that the Popular Posts will display thumbnail with horizontal title. If you want to install the such Popular Posts just follow the guides below.

Step 1. Login to your Blogger.com.

Step 2. Now head to Template, then find this code ]]></b:skin>, and put the following code right above it.
.PopularPosts .widget-content ul li {background:none repeat scroll 0 0 transparent;float:left;list-style:none outside none;margin:0 !important;padding: 0 !important;border-bottom:none}
.PopularPosts ul{padding:5px 0}
.PopularPosts .item-thumbnail img{width:110px;height:110px;padding:11px;margin:0}
.PopularPosts .item-content{position:relative;float:left;margin:0}
.PopularPosts .item-title a{font-size:11px;color:#fff;display:block;padding:0 5px;float:left;width:122px}
.PopularPosts .item-title:hover{opacity:1;-moz-opacity:1;filter:alpha(opacity=100)}
.PopularPosts .item-thumbnail{float:left;margin:3px 1px 7px 10px;border:1px solid #ccc;overflow: hidden}
.PopularPosts .item-title{background:#000;position:absolute;bottom:8px;right:2px;opacity:.6;-moz-opacity:.6;filter:alpha(opacity=6)}
The red code on the above CSS codes is referring to the length and width of the thumbnail, you can change it according your need or to match with the size of your sidebar.
Step 3.  Now go to layout >> add a gadget, select Popular Post.

Step 4. Now you will see the Popular Post setting box / window to configure its appearance. Like in the following picture.

Step 5. What you need to notice; just check on the thumbnail only, and leave the Snippet un-checked. As for the number of titles and posts is totally your choice. You decide by yourself how many title should be appearing.
Now we have to edit the Popular Post code to make it appear like in the picture above.
Step 6. After you done with the above step, now back to the Template, then find this code.
<b:widget id='PopularPosts1' locked='false' title='Popular Posts' type='PopularPosts'>
<b:includable id='main'>
<b:if cond='data:title'><h2>
<data:title/></h2>
</b:if>
<div class='widget-content popular-posts'>
<ul><b:loop values='data:posts' var='post'>
<li>
<b:if cond='data:showThumbnails == &quot;false&quot;'>
<b:if cond='data:showSnippets == &quot;false&quot;'>
<!-- (1) No snippet/thumbnail -->
<a expr:href='data:post.href'><data:post.title/></a>
<b:else/>
<!-- (2) Show only snippets -->
<div class='item-title'>
<a expr:href='data:post.href'><data:post.title/></a></div>
<div class='item-snippet'>
<data:post.snippet/></div>
</b:if>
<b:else/>
<b:if cond='data:showSnippets == &quot;false&quot;'>
<!-- (3) Show only thumbnails -->
<div class='item-thumbnail-only'>
<b:if cond='data:post.thumbnail'>
<div class='item-thumbnail'>
<a expr:href='data:post.href' target='_blank'>
<img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
</a>
</div>
</b:if>
<div class='item-title'>
<a expr:href='data:post.href'><data:post.title/></a></div>
</div>
<div style='clear: both;'/>
<b:else/>
<!-- (4) Show snippets and thumbnails -->
<div class='item-content'>
<b:if cond='data:post.thumbnail'>
<div class='item-thumbnail'>
<a expr:href='data:post.href' target='_blank'>
<img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
</a>
</div>
</b:if>
<div class='item-title'>
<a expr:href='data:post.href'><data:post.title/></a></div>
<div class='item-snippet'>
<data:post.snippet/></div>
</div>
<div style='clear: both;'/>
</b:if>
</b:if>
</li>
</b:loop> </ul>
<b:include name='quickedit'/>
</div>
</b:includable>
</b:widget></pre>
<b>Step 7</b>. After you found it, then replace the above code with the following code.
<pre class="brush: html; auto-links: false; html-script: false;"><b:widget id='PopularPosts1' locked='false' title='Most Product View' type='PopularPosts'>
<b:includable id='main'>
<b:if cond='data:title'><h2>
<data:title/></h2>
</b:if>
<div class='widget-content popular-posts'>
<ul><b:loop values='data:posts' var='post'>
<li>
<b:if cond='data:showThumbnails == &quot;false&quot;'>
<b:if cond='data:showSnippets == &quot;false&quot;'>
<!-- (1) No snippet/thumbnail -->
<a expr:href='data:post.href'><data:post.title/></a>
<b:else/>
<!-- (2) Show only snippets -->
<div class='item-title'>
<a expr:href='data:post.href'><data:post.title/></a></div>
<div class='item-snippet'>
<data:post.snippet/></div>
</b:if>
<b:else/>
<b:if cond='data:showSnippets == &quot;false&quot;'>
<!-- (3) Show only thumbnails -->
<div class='item-content'>
<b:if cond='data:post.thumbnail'>
<div class='item-thumbnail'>
<a expr:href='data:post.href' target='_blank'>
<img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
</a>
</div>
</b:if>
<div class='item-title'>
<a expr:href='data:post.href'><data:post.title/></a></div>
</div>
<div style='clear: both;'/>
<b:else/>
<!-- (4) Show snippets and thumbnails -->
<div class='item-content'>
<b:if cond='data:post.thumbnail'>
<div class='item-thumbnail'>
<a expr:href='data:post.href' target='_blank'>
<img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
</a>
</div>
</b:if>
<div class='item-title'>
<a expr:href='data:post.href'><data:post.title/></a></div>
<div class='item-snippet'>
<data:post.snippet/></div>
</div>
<div style='clear: both;'/>
</b:if>
</b:if>
</li>
</b:loop> </ul>
<b:include name='quickedit'/>
</div>
</b:includable>
</b:widget>
Done! You can now save your template.

No comments:

Post a Comment