Monday, 2 July 2012

New Stylish Blog Related Posts


what-next-widget-for-blogger
Are you excited with the widget shown above??? Want to add this  to your blog, then just follow the steps mentioned below. Please create a back up of your template before you install this widget.
            To do this, navigate to "Design->Edit HTML" and make a backup of your template clicking on the "Download full template" link at the top. Once the back up is over, follow these steps carefully.
1. Expand your template, that is, make sure you have a tick mark in box next to "Expand Widget Template". Now, search using "CTRL+F" for the following line:
<data:post.body/>
<div style='clear: both;'/>
</div>
2.Copy the code below. Paste the code just below the line you searched in step1.
<div class='cps'>
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-YOURADSENSECODE&quot;;
google_ad_host = &quot;pub-1556223355139109&quot;;
/* 468x15, created 10/15/10 */
google_ad_slot = &quot;2917101792&quot;;
google_ad_width = 468;
google_ad_height = 15;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;</div>

<div id='end'>
<ul class='actions'>
<h3>What&#39;s Next?</h3>
<li><a class='digg' expr:href='&quot;http://digg.com/submit?phase=2&amp;url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' rel='nofollow' target='_blank'>Digg it</a></li>
<li><a class='stumble' expr:href='&quot;http://www.stumbleupon.com/refer.php?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' rel='nofollow' target='_blank'>StumbleUpon</a></li>
<li><a class='delicious' expr:href='&quot;http://del.icio.us/post?url=&quot; + data:post.url + &quot;&amp;title=&quot; + data:post.title' rel='nofollow' target='_blank'>Save on Del.icio.us</a></li>
<li><a class='subscribemini' href='http://feeds2.feedburner.com/EverythingAboutBlogging' rel='nofollow'>Subscribe via RSS</a></li>
<li><a class='comment' expr:href='data:post.addCommentUrl' expr:onclick='data:post.addCommentOnclick' rel='nofollow'>Leave a comment</a></li>
</ul>
<ul class='tips'>
<h3>Other Recommended Posts</h3>
<li><div style='display:none;'><b:loop values='data:post.labels' var='label'><data:label.name/><b:if cond='data:label.isLast != &quot;true&quot;'>,</b:if><b:if cond='data:blog.pageType == &quot;item&quot;'>
<script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name +   &quot;?alt=json-in-script&amp;callback=related_results_labels&amp;max-results=5&quot;' type='text/javascript'/></b:if></b:loop></div>
<script type='text/javascript'> removeRelatedDuplicates(); printRelatedLabels(); </script></li></ul>
</div>

Note: Replace "YOUR ADSENSE CODE" text in the file with your Account ID. Account ID will be found in the top right corner of the Adsense Dashboard. Take a look at the screen shot below for better understanding.  


3. Now, its time to add the CSS part for your widget. Search for the following line in your template.
]]></b:skin>
4. Copy the following code and paste it just above the line mentioned in step3.
.cps {
background:none repeat scroll 0 0 #ddd;
border-top:3px solid #000;
margin-top:5px;
padding:10px;
width:570px;
}
#end {
-moz-background-inline-policy:continuous;
background:none repeat scroll 0 0 #f9f9f9;
border-bottom:3px solid #000;
border-top:3px solid #000;
float:left;
font-family:arial;
font-size:12.2px;
margin:0 0 40px;
padding:14px 0 12px 25px;
width:565px;
}
.actions {
float:left;
margin:0 20px 0 0;
padding-left:0;
padding-top:0;
text-align:left;
width:23%;
}
.tips {
float:left;
margin:0;
padding-left:0px;
padding-top:0;
text-align:left;
width:65%;
}
#end ul.tips li {
-moz-background-inline-policy:continuous;
background:url() no-repeat scroll 0 3px transparent;
margin:0 0 9px;
padding-left:14px;
margin-left:-34px;
}
a.digg {
-moz-background-inline-policy:continuous;
background:url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfVN4cm58bkKIVfHkRJoptjpg8lYMhxxhkvLMeVMaWDRr-bdjw3wkRVdHIuPCS5Ivked0MEhAhZn4aeEv51TjFTe76_iBEyAOGsLXKA8FV208Wgx7T600GZ1pMLj9d5fwD667UBhTOjLA/s400/digg-1.png") no-repeat scroll 0 1px transparent;
padding:2px 0 2px 20px;
}
#end ul.actions li {
-moz-background-inline-policy:continuous;
background:none repeat scroll 0 0 transparent;
margin:0 0 9px;
}
#end ul li {
}
#end ul {
list-style-type:none;
}
a.delicious {
-moz-background-inline-policy:continuous;
background:url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt4e5xH-qzIyT7OkNsk8ivabegjUtQGe2S0uDnrOFNc7dlB6tb_gxha6nFZsPLKQzgDLEnLX14Cf7PACrZrSKATQozI27c8AcjF7wyoPZDb6A-xN3hSy3KxWUUdXNZUGXaqgRBSAw9CMg/s400/delicious-1.png") no-repeat scroll 0 2px transparent;
padding:2px 0 2px 20px;
}
a.subscribemini {
-moz-background-inline-policy:continuous;
background:url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuJqaO3gZup3sGJLnCD3EpaXcpuVd9vV1o2jI3ERo471FwaE5gWLe65aVlaXOdUwTsuRz0g4Cmv8AIL480SiZndImnrJU-g4Pnb2pNXSoZ-65-_3XKEjO9oOu2qEafkbizSwUZqY8gjF4/s400/feed.png") no-repeat scroll 0 1px transparent;
padding:2px 0 2px 20px;
}
a.comment {
-moz-background-inline-policy:continuous;
background:url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYXD6TXuBoonzRmEebP_Tod-TTxmWAJ4oXBh8um2A7qQjwkv5F8Vykgnnm-heuf3mWQ_yAZ5jB0NHmo3T1Ynkgmr4JD7Ml0vgicApMqA1EmjDHG1G6jEG4gEis2VSbQ3TIU9HG10Fk9nc/s400/comment.gif") no-repeat scroll 0 0 transparent;
padding-left:20px;
}
a.stumble {
-moz-background-inline-policy:continuous;
background:url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkcQNmTh_EEHxIaZ6rF19XHWRVw6-O94Ao86JJbTyx34UcJIl8saxAgQa7cI2t3mjfk2boyNXzHxj2anZ2wy9X0k-44tXpqUaxktdRgkrSmFVewFlTleNwkwAgp450kFWDvFLx5rfd9JE/s400/stumble.png") no-repeat scroll 0 1px transparent;
padding:2px 0 2px 20px;
}
a.twit {
-moz-background-inline-policy:continuous;
background:url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhctfRJ3MTnJLhwQee1QvwxMAO3cBwnRjJx-00po2jobpniOqIZfvtA-KGzgR2qtZTlDTqxwe7N_IwcLqTmORWdR-U-k9IYDiAthoKilGgcH6OnKXJQe8WmasY34_6WHSXXc1YPJW-ja5Q/s400/twitter_16.png") no-repeat scroll 0 0 transparent;
padding-left:20px;
}
#end h3 {
color:#000000;
font-size:13px;
margin-bottom:11px;
margin-top:4px;
font-weight:bold;
}
.hidden {
display:none;
}
Note: If you wish to change the background or the border color, then change the codes highlighted in green. For any other customization regarding this widget, leave your comments below and I will try to customize them as you wish.
5. Now, its time to add the javascript part for your widget. To add the script, search for the following line on your blogger template.
</head>
Now, paste the following piece of code just above the line mentioned in step 5.
<script type='text/javascript'>
//<![CDATA[
var relatedTitles = new Array();
var relatedTitlesNum = 0;
var relatedUrls = new Array();
function related_results_labels(json) {
for (var i = 0; i < json.feed.entry.length; i++) {
var entry = json.feed.entry[i];
relatedTitles[relatedTitlesNum] = entry.title.$t;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
relatedUrls[relatedTitlesNum] = entry.link[k].href;
relatedTitlesNum++;
break;
}
}
}
}
function removeRelatedDuplicates() {
var tmp = new Array(0);
var tmp2 = new Array(0);
for(var i = 0; i < relatedUrls.length; i++) {
if(!contains(tmp, relatedUrls[i])) {
tmp.length += 1;
tmp[tmp.length - 1] = relatedUrls[i];
tmp2.length += 1;
tmp2[tmp2.length - 1] = relatedTitles[i];
}
}
relatedTitles = tmp2;
relatedUrls = tmp;
}
function contains(a, e) {
for(var j = 0; j < a.length; j++) if (a[j]==e) return true;
return false;
}
function printRelatedLabels() {
var r = Math.floor((relatedTitles.length - 1) * Math.random());
var i = 0;
document.write('<ul>');
while (i < relatedTitles.length && i < 20) {
document.write('<li><a href="' + relatedUrls[r] + '">' + relatedTitles[r] + '</a></li>');
if (r < relatedTitles.length - 1) {
r++;
} else {
r = 0;
}
i++;
}
document.write('</ul>');
}
//]]>
</script>
6. That's it!!! Save your template. View the widget on your post pages.

Note: You need to view the post pages to view the widget. That is, click on any of the posts in your blog to view the final result. You cannot find them on the home page of your blog.

0 comments:

Post a Comment

newer post older post Home