Saturday, 15 February 2014

jQuery Sliding Panel with Expanding/Collapsing Content for Blogger

Many times when we think about creating a blog, we tend to put many gadgets, although many are not necessary, or perhaps only a few of them. In order to add the gadgets that we want, we need to have enough space. A solution would be to use an expanding/collapsing menu that is hidden and expands when the user clicks on it.

Originally, this plugin called Sliding Login Panel was created so that users could register on the site, but as we know, in Blogger we don't have the option to add user registration, but that doesn't mean we can't take advantage of this plugin and use it to add other elements, such as a menu, search box, social icons, feed subscription etc.


You can find a demo of this panel in this blog - just click on the Open menu link on the top.

Adding the jQuery Expand/Collapse Slider Panel to Blogger

This sliding menu is made with jQuery, so the first thing is to add the script by pasting it just below the <head> tag:

Step 1. From your Blogger dashboard > go to "Template" > click on the "Edit HTML" button:

blogger template

Step 2. Click anywhere inside the code area and search by pressing the CTRL + F keys for the <head> tag

Step 3. Below the <head> tag, add this script:
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript'></script>
<script type='text/javascript'>
$(document).ready(function() {

$(&quot;#open&quot;).click(function(){
$(&quot;div#panel&quot;).slideDown(&quot;slow&quot;);
});

$(&quot;#close&quot;).click(function(){
$(&quot;div#panel&quot;).slideUp(&quot;slow&quot;);
});

$(&quot;#toggle a&quot;).click(function () {
$(&quot;#toggle a&quot;).toggle();
});

});</script>

<b:if cond='data:blog.pageType != &quot;item&quot;'>
<style>
body#layout #slide-top-panel {display:none !important;}
</style>
</b:if>

Step 4. Now search (CTRL + F) the </head> tag and add the CSS styles just above it:
<style>
.clearfix:after {content: ".";display: block;height: 0;clear: both;visibility: hidden;}
.clearfix {display: inline-block;}
* html .clearfix {height: 1%;}
.clearfix {display: block;}
.clearfix {height: 1%;}
.clearfix {display: block;}

.tab {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6ObQNfxgA6YYWxxnbFcZ3J20ePCrVQ9EXx1MEAapM9aHatsCIcpQrWYqPUZbsaBHBjoZqOW_PDTYyugswJgjnXY-M9DLwt2S_nb8wKBPZn_IU7-5XlvYp34GqnlSGAacAzxYO6LKEj7R2/s1600/sliding-panel-tab-0.png) repeat-x 0 0;
height: 42px;
position: relative;
top: 0;
z-index: 999;
}
.tab ul.login {
display: block;
position: relative;
float: right;
clear: right;
height: 42px;
width: auto;
font-weight: bold;
line-height: 42px;
margin: 0;
right: 150px;
color: white;
font-size: 80%;
text-align: center;
}
.tab ul.login li.left {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzbmEj5KZgHd-PTPufDP0lpUIZaDmo6PdPdxmE5-t-FYfoz4NMt_iCZeSYUQDGUWlsCy6UxXwKVdGm-f58xbtkRJK53ezxXYdkACg4QWMkMy6_p3u-366-_12Z3sVG0yoBkkfaj0CDd43H/s1600/sliding-panel-tab-left.png) no-repeat left 0;
height: 42px;
width: 30px;
padding: 0;
margin: 0;
display: block;
float: left;
}
.tab ul.login li.right {
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsjE91fvjYv9VLCUwpThuPREMu0yaRbykh3LRg6-w0LnBAwvAKwXpCRatmW21y44G06ffXG5E5PU9GdDafs6jcFQV8REylj1UU5yo5A-Ez7zHdxhg-McNlOwhhERUoJhRRO3qp1GfqRshh/s1600/sliding-panel-tab-right.png) no-repeat left 0;
height: 42px;
width: 30px;
padding: 0;
margin: 0;
display: block;
float: left;
}
.tab ul.login li {
text-align: left;
padding: 0 6px;
display: block;
float: left;
height: 42px;
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqzXn95vPjzS76TUKNRO_0CC8g5REPtRy3uZFODhY1pvjMLF9k0lwVWis_VZTWZ3ZUux4sIpd9VPZkKhpXLG55eKySWHiLIkXHlDKPdwEOj1NqELiU-WF6z7rM4zzNPeID8VFFBFVen1Ud/s1600/sliding-panel-tab.png) repeat-x 0 0;
}

.tab ul.login li a {color: #15ADFF;}
.tab ul.login li a:hover {color: #FFFFFF;}
.tab .sep {color:#414141}

.tab a.open, .tab a.close {
height: 20px;
line-height: 20px !important;
padding-left: 30px !important;
cursor: pointer;
display: block;
width: 100px;
position: relative;
top: 11px;
}

.tab a.open {background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfhomwvZ8l37cVXQfvq6GQFnx5MkovWSggRQbB1_puFN0jrV1DWFqPK6lPs_4WXvW5WZLgstihf0dD0IKqw5_jpJhRzIm3DLCj6RuIoSoJPy35F0Gs43Vm4m0_e28pKjsEo1jTcUG4Eymk/s1600/button-open.png) no-repeat left 0;}
.tab a.close {background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNKjgW82H4vH53_bKDjVyRP6m5JHbkmD1oCaEqbHhuuh-dKAKAkzEZygTN3kuUxNEH6lb35fyar-bGMMqeni_csLz_96t_fYtz7-wtCVYtZRNLqG2mNULV8pTjTNfMs4-F70LMrrBJsP0y/s1600/button-close.png) no-repeat left 0;}
.tab a:hover.open {background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfhomwvZ8l37cVXQfvq6GQFnx5MkovWSggRQbB1_puFN0jrV1DWFqPK6lPs_4WXvW5WZLgstihf0dD0IKqw5_jpJhRzIm3DLCj6RuIoSoJPy35F0Gs43Vm4m0_e28pKjsEo1jTcUG4Eymk/s1600/button-open.png) no-repeat left -19px;}
.tab a:hover.close {background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNKjgW82H4vH53_bKDjVyRP6m5JHbkmD1oCaEqbHhuuh-dKAKAkzEZygTN3kuUxNEH6lb35fyar-bGMMqeni_csLz_96t_fYtz7-wtCVYtZRNLqG2mNULV8pTjTNfMs4-F70LMrrBJsP0y/s1600/button-close.png) no-repeat left -19px;}

#slide-top-panel {
position: absolute;
top: 0;
width: 100%;
z-index: 999;
text-align: center;
margin-left: auto;
margin-right: auto;
}
#panel {
width: 100%;
height: 230px;
color: #999999;
background: #272727;
overflow: hidden;
position: relative;
z-index: 3;
display: none;
}
#panel h4 {
font-size: 18px;
color: #F2F2F2;
text-align: center;
padding: 5px 0 10px;
margin: 0;
}
#panel p {
margin: 5px 0;
padding: 0px;
}
#panel a {
text-decoration: none;
color: #15ADFF;
}
#panel a:hover {
color: white;
}
#panel .content {
width: 960px;
margin: 0 auto;
padding-top: 15px;
text-align: left;
font-size: 0.85em;
}
#panel .content .left {
width: 280px;
float: left;
padding: 0 15px;
border-left: 1px solid #333;
}
#panel .content .right {
border-right: 1px solid #333;
}
#panel .content form {
margin: 0 0 10px 0;
}
#panel .content label {
float: left;
padding-top: 8px;
clear: both;
width: 280px;
display: block;
}
#panel .content input.field {
border: 1px #1A1A1A solid;
background: #545454;
border-radius: 10px;
margin-right: 5px;
margin-top: 4px;
width: 200px;
color: white;
height: 18px;
}
#panel .content input:focus.field {
background: #7F7F7F;
}
#panel .content input.button-register {
display: block;
clear: both;
height: 24px;
width: 94px;
color: white;
background: transparent url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSTgMLo-c_Ns5kU4zTEeFQVWZl5aHCvIgtV7MXYyUOJnpNtK8MTVc4jF_6Z7WoBdonhH9foWAIuPVH17Px8bLtxpZPgZLVlK_q29N50FA4MTh_VTftn7EyY2xq5xzL2sdFtUhgjkmvcAkN/s1600/button-register.png) no-repeat 0 0;
text-align: center;
cursor: pointer;
border: none;
font-weight: bold;
margin: 10px auto;
}
#sliding-panel {
width: 160px;
float: left;
}
#sliding-panel2 {
width: 160px;
float: right;
}
#sliding-panel ul, #sliding-panel2 ul{
font-family: Arial, Helvetica, sans-serif;
list-style-type:none;
margin:0;
padding:0;
}
#sliding-panel ul li a, #sliding-panel2 ul li a {
background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoE3a7jUsDbybUveIIqS2HyU1VgDFwprn6MNZnWrGnh4hqnBRfqBKCRB95n6JF9fV3DcDIaQPitSNGBu_kYkXs7QTV9GFS6f_hkbOtEi-djU_O1Q9_ZO-P59KuRSf7UxFtR3loL3ifxOgP/s1600/star-bullet.png) center left no-repeat;
margin:0;
padding:3px 3px 3px 18px;
}
#sliding-panel li, #sliding-panel2 li {
display: inline;
}
#sliding-panel a, #sliding-panel2 a{
color: #999999;
text-decoration: none;
font-size: 11px;
display: block;
padding: 3px;
width: 160px;
}
#sliding-panel a:link, #sliding-panel a:visited, #sliding-panel2 a:link, #sliding-panel2 a:visited {
color: #999999;
text-decoration: none;
}
#sliding-panel a:hover, #sliding-panel2 a:hover {
color: #FFFFFF;
}

#search-box22{
margin-top: 20px;
}

#search-box22 input[type="text"] {
float: right;
background: 10px 6px #444;
border: 0 none;
font: bold 12px Arial,Helvetica,Sans-serif;
color: #777;
width: 160px;
padding: 6px 15px 6px 35px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-webkit-transition: all 0.7s ease 0s;
-moz-transition: all 0.7s ease 0s;
-o-transition: all 0.7s ease 0s;
transition: all 0.7s ease 0s;
}

#search-box22 input[type="text"]:focus {
width: 190px;
}

.about-author {
width: 100%;
text-transform: none;
margin-top: 15px;
}
.authorbox {
overflow: hidden;
padding: 0;
width: 100%;
}
.authorbox .authorinfo {
}
.authorbox .authorinfo img {
float: left;
margin: 4px 10px 4px 5px;
border-radius: 100%;
width: 20%;
background: #222;
padding: 5px;
}
.authorbox .authorinfo p {
margin: 0;
padding: 0 5px;
text-align: left;
}
.authorinfo p a {
text-decoration:none;
}
.authorbox h3 {
margin: 0;
display: inline-block;
}
h3.boxtitle {
font-size: 14px;
}
</style>
Note:
  • in case you need more space for your widgets, the height of the entire container can be changed by modifying the 230px value from height: 230px;
  • To change the background color, change this color value: #272727
Step 5. And finally, we will place the HTML structure of it. Right after the <body> tag, add this code:
<!-- Start sliding panel -->
<div id='slide-top-panel'>
<div id='panel'>
<div class='content clearfix'>

<!-- first section -->
<div class='left' style='width:240px !important'>

<h4>Welcome to my blog!</h4>
<div class='about-author'>
<div class='authorbox'>
  <div class='authorinfo'>
<img src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJE4PINo77YEceoLkwAf4Hzl3X5bF-_8zFsvAnaMBSJ090GTSkpPxdc-X3fe0i6crUKlPoBDUh5kbSVKazV8PmB6xT2amCG9LJUVSCyZdtawFErFJBNKHoNK6KIz-4Bn0gRX3X4sVqxAyi/s1600/profile-pic.png'/>
<h3 class='boxtitle'>Meet the Author</h3>
<p>Ut eleifend tortor aliquet, fringilla nunc non, consectetur magna. Suspendisse potenti.</p>
</div>
</div>
</div>
<p align="right" style="margin-top: 10px;">Looking for something?</p>
<form method="get" action="/search" id="search-box22">
  <input name="q" type="text" size="40" placeholder="Search..." />
</form>

</div>

<!-- second section -->
<div class='left' style='width:320px !important'>
<h4>Categories</h4>

<div id='sliding-panel'>
<ul>
<li><a href='Link URL'>Category 1</a></li>
<li><a href='Link URL'>Category 2</a></li>
<li><a href='Link URL'>Category 3</a></li>
<li><a href='Link URL'>Category 4</a></li>
<li><a href='Link URL'>Category 5</a></li>
<li><a href='Link URL'>Category 6</a></li>
<li><a href='Link URL'>Category 7</a></li>
</ul>
</div>

<div id='sliding-panel2'>
<ul>
<li><a href='Link URL'>Category 1</a></li>
<li><a href='Link URL'>Category 2</a></li>
<li><a href='Link URL'>Category 3</a></li>
<li><a href='Link URL'>Category 4</a></li>
<li><a href='Link URL'>Category 5</a></li>
<li><a href='Link URL'>Category 6</a></li>
<li><a href='Link URL'>Category 7</a></li>
</ul>
</div>
</div>

<!-- third section -->
<div class='left right' align="center">

<h4>Subscribe to this blog!</h4>
<p style="padding:0px 30px;">Receive the latest posts by email. Just enter your email below if you want to subscribe!</p>

<form action='http://feedburner.google.com/fb/a/mailverify?uri=Feed-Name' method='post' target='_blank'>
<input class='field' name='email' type='text/' value=''/>
<input name='uri' type='hidden' value='Feed-Name'/>
<input name='lang' type='hidden' value='en_EN'/>
<input class='button-register' type='submit' value='Subscribe'/></form>

<div align='center' style="clear: both;">
<a href='http://www.facebook.com/username'><img title="Follow on Facebook" src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilQAgV0sNqrnqlp2Z80lkOq3lNdu-05_NfQ62_-0Y6kUE92Dkck0yJNGi7gE7p-GXtp-wDLencC6zMtJW-jrmKz-nUdyCXRTthkFsNvRKrvOMFjudA7iLqcck-kDC1rtmzQvwTNyGOHjYc/s1600/Facebook.png' style='padding:5px;' width='32'/></a>
<a href='http://blog-address.blogspot.com/atom.xml'><img title="RSS Feed" src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVGl7UkYCB694wLfLOst0W76ks6Xbe4Yc3pS03qyhbeqau124NFa3dCwQuo8lfF5zKDd1DLeKPmKSVs6wzsetYVozl_UHO4kwCK79HCdy8N3kxASf9PKdBrrBOMsnq_DSNIQ4P3fRKmyJc/s1600/RSS.png' style='padding:5px;' width='32'/></a>
<a href='https://plus.google.com/username'><img title="Follow on Google" src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmbezovyk0PLnDJDuAa2pV37cIBIl74qyCgcFiZRktAEruH_EINwg5ao9Hnk9kdtR3Gmq_5GSPk9HKz2vdAcxfp2uWZBmraHZ6BHf936Mc5CjeNENaLSJU71cleMD5WK0HMePCxMSbAQ93/s1600/Google-plus.png' style='padding:5px;' width='32'/></a>
<a href='http://twitter.com/username'><img title="Follow on Twitter" src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeVm03EaRz81VYlRT1wPQ9shQ6DoEArrJO5DIot-Mu7jvT-bdZmshrCeIytEsIHoku3TRD9oWs2HXUgjHNP5Mnk4W_DfXH6ZcqWAH5cy9yCltYdodGjfKruCFULPAfi5PVRhIMVcXMyeZR/s1600/Twitter.png' style='padding:5px;' width='32'/></a>
</div>

</div>
</div>
</div>

<div class='tab'>
<ul class='login'>
<li class='left'/>
<li>Hello guest!</li>
<li class='sep'>|</li>
<li id='toggle'>
<a class='open' href='#' id='open'>Open menu</a>
<a class='close' href='#' id='close' style='display: none;'>Close menu</a>
</li>
<li class='right'/>
</ul>
</div>
</div>
Note: if you can't find the <body> tag, then try to find this one:
<body expr:class='&quot;loading&quot; + data:blog.mobileClass'>
Here we have added the content in the sliding panel which will be hidden and will show on mouse click. In green are the names of each section so it is easier to recognize them.

Note:
  • In the first section, you can change the welcome message, "Meet the author" title and add your description by replacing the text in bold. To add your own picture, replace this URL:
  • https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJE4PINo77YEceoLkwAf4Hzl3X5bF-_8zFsvAnaMBSJ090GTSkpPxdc-X3fe0i6crUKlPoBDUh5kbSVKazV8PmB6xT2amCG9LJUVSCyZdtawFErFJBNKHoNK6KIz-4Bn0gRX3X4sVqxAyi/s1600/profile-pic.png
  • In the second section you have the categories - there add the URLs of your links by replacing the addresses in blue and replace Category 1, 2, 3... with the titles that you want to appear for the links.
  • In the third section is the email subscription - just replace the text in blue with the name of your blog's feed. Please note that you must have this email subscription option enabled in your Feedburner account.
  • As for the social icons below, change the URLs in blue with your Facebook and Twitte and add the URL of your blog's RSS feed address.
Basically, these are the main sections that can be customized, but we can remove some of them and paste something else instead.

Step 6. Save the template and that's it! Note that this menu works with jQuery, so if you are already using Scriptaculous, Prototype or Mootools, then it will not work.

Hope you'll enjoy this elegant menu with sliding effect, which will look way better if we remove the Blogger navbar.

Tuesday, 11 February 2014

How to Display Adsense Ads within Blogger Posts (Not in the End)

In the beginning you need to enable Ads in the post by going to layout and edit the Blog Posts. Here you will get an option "Show Ads between Posts". Enable it and choose the size of Ads.

By using this simple technique the ads are displayed at the end of posts, and between first three posts on the homepage. But what if you don't want to display them on homepage or don't want to display them at the end of post, but in the starting of post.


To do these things now you have to edit the template code. Before you take that step please take backup of your template code and then apply the trick that i have mentioned below.

You have to find the blogger Ad code. Find the code given below in your template coding. Cut it and paste it in a separate notepad file.

Adcode:

<b:if cond='data:post.includeAd'>
        <b:if cond='data:post.isFirstPost'>
          <data:defaultAdEnd/>
        <b:else/>
          <data:adEnd/>
        </b:if>
        <div class='inline-ad'>
          <data:adCode/>
        </div>
        <data:adStart/>
      </b:if>



Find     <b:loop values='data:posts' var='post'>

And paste the above adcode just below it.

If you want to display the ads on a side of main content of the post, then put the adcode within the div provided below.

<div style='float:left'>
<!-- AdCode Here -->
</div>

Here style='float:left' will put the ad on the left side of main post content. You can also set it to right if you desire so.

If you want to display Ads only in Posts, not on the homepage. Then put the code within the if loop provided below.

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<!-- AdCode Here -->
</b:if>

If you implement all things explained above then your code will look like this

<b:loop values='data:posts' var='post'>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div style='float:left'>
      <b:if cond='data:post.includeAd'>
        <b:if cond='data:post.isFirstPost'>
          <data:defaultAdEnd/>
        <b:else/>
          <data:adEnd/>
        </b:if>
        <div class='inline-ad'>
          <data:adCode/>
        </div>
        <data:adStart/>
      </b:if>
</div>
</b:if>

Monday, 10 February 2014

How to customize or edit the linkwithin related post widget

LinkWithin is a very popular widget that shows the related posts with a thumbnail and although it is not a new gadget among bloggers, many avoid using it for its lack of customization. So, this tutorial will show you how to add LinkWithin on a Blogger blog and how to customize it.

This is what we will do with this gadget:
  • Change the location of the gadget;
  • Remove the LinkWithin link;
  • Change the "You might also like" title with any other text;
  • Add rounded borders to images;
  • Remove the border that separates posts;
  • Add a background color;
  • Change the background color on mouse over;
  • Change the post titles color and font

Adding the LinkWithin gadget to Blogger

First of all we need to install the LinkWithin gadget. For this, we have to go to the LinkWithin homepage and type in the required information:

linkwithin gadget, related posts widget, blogger widgets
Although it provides the option to choose Blogger as a platform, we will select Other in order to implement the code directly into our template and then modify it. Select the number of posts (stories) according to the width of the content area - if the width of the posts container is narrower, then it is recommended to display fewer related posts.

By clicking on the "Get widget!" button, we'll be given the code that we need use it. It should look something like this:
<script>
var linkwithin_site_id = XXXXXXX;
</script>
<script src="http://www.linkwithin.com/widget.js"></script>
<a href="http://www.linkwithin.com/"><img src="http://www.linkwithin.com/pixel.png" alt="Related Posts Plugin for WordPress, Blogger..." style="border: 0" /></a>
That's the basic code we need to copy. Now login into your Blogger account > select your blog to where you want to add the LinkWithin gadget and go to "Template" > click on the "Edit HTML" button:


Cick anywhere inside the code area and press the CTRL + F keys to search for the following line:
<div class='post-footer'>
Just above this line, paste the LinkWithin code.

By doing so you already have the LinkWithin gadget on your blog and the result will be like this:

linkwithin gadget, related posts widget, blogger widgets
Note: If you would like to display it only in post pages, you can enclose the code using a Blogger conditional tag.

Change the LinkWithin gadget location

By default, this widget will always appear right at the end of your posts. In the LinkWithin FAQ page we can find solutions on how to fix this - simply add the code below where we want the widget to appear:
<div class='linkwithin_div'/>
This will make the gadget to display right where we added the code. Even if we don't want to change the gadget location, this line is required so that we can customize it later.

Replacing the "You might also like" LinkWithin text

By default, the LinkWithin gadget shows the "You might also like" title but we can change the text to anything we want. Just add the line below in blue within the LinkWithin code:
<div class='linkwithin_div'/>
<script>
var linkwithin_site_id = XXXXXXX;
</script>
<script>linkwithin_text='Related Posts:'</script>
<script src="http://www.linkwithin.com/widget.js"></script>
<a href="http://www.linkwithin.com/"><img src="http://www.linkwithin.com/pixel.png" alt="Related Posts Plugin for WordPress, Blogger..." style="border: 0" /></a>
And change the text - in this case, it will show "Related posts" instead of "You may also like these stories".

Changing the LinkWithin background color and thumbnails style

Within the template's code, search for the ]]></b:skin> tag and just above it, add the following CSS styling:
.linkwithin_div {
background: #EEEEEE; /* Background color for the related posts container */
padding: 0 10px;
border-top: 1px solid #DBDBDB;  /* Top border for the related posts container */
border-bottom: 1px solid #DBDBDB;  /* Bottom border for the related posts container */
}
.linkwithin_text {
font-family: Cambria,Georgia,sans-serif;
font-size:18px; /* Size for the related posts title */
color:#898989; /* Color for the related posts title */
}
a#linkwithin_logolink_0, a#linkwithin_logolink_1, a#linkwithin_logolink_2, a#linkwithin_logolink_3, a#linkwithin_logolink_4, a#linkwithin_logolink_5, a#linkwithin_logolink_6, a#linkwithin_logolink_7, a#linkwithin_logolink_8, a#linkwithin_logolink_9, a#linkwithin_logolink_10, a#linkwithin_logolink_11, a#linkwithin_logolink_12, a#linkwithin_logolink_13, a#linkwithin_logolink_14, a#linkwithin_logolink_15, a#linkwithin_logolink_16, a#linkwithin_logolink_17, a#linkwithin_logolink_18, a#linkwithin_logolink_19, a#linkwithin_logolink_20 {
display:none;
}
.linkwithin_posts {
width: 500px !important; /* Width for the related posts container */
}
.linkwithin_posts a {
border: 0 !important;
padding-right: 10px !important;
}
.linkwithin_posts a:hover {
background: #F5F5F5 !important; /* Background color on mouseover */
}
.linkwithin_img_0 {
background: #F5F5F5;
border: 1px solid #C1C1C1;
padding: 2px !important;
transition:all .2s linear;
 -o-transition:all .5s linear;
-moz-transition:all .2s linear;
-webkit-transition:all .2s linear;
}
.linkwithin_img_0:hover {
background: #ffffff;
padding: 2px !important;
opacity:.6;
filter:alpha(opacity=60)

.linkwithin_img_0 div, div.linkwithin_img_0,
.linkwithin_img_1 div, div.linkwithin_img_1,
.linkwithin_img_2 div, div.linkwithin_img_2,
.linkwithin_img_3 div, div.linkwithin_img_3,
.linkwithin_img_4 div, div.linkwithin_img_4,
.linkwithin_img_5 div, div.linkwithin_img_5,
.linkwithin_img_6 div, div.linkwithin_img_6,
.linkwithin_img_7 div, div.linkwithin_img_7,
.linkwithin_img_8 div, div.linkwithin_img_8,
.linkwithin_img_9 div, div.linkwithin_img_9,
.linkwithin_img_10 div, div.linkwithin_img_10,
.linkwithin_img_11 div, div.linkwithin_img_11,
.linkwithin_img_12 div, div.linkwithin_img_12,
.linkwithin_img_13 div, div.linkwithin_img_13,
.linkwithin_img_14 div, div.linkwithin_img_14,
.linkwithin_img_15 div, div.linkwithin_img_15,
.linkwithin_img_16 div, div.linkwithin_img_16,
.linkwithin_img_17 div, div.linkwithin_img_17,
.linkwithin_img_18 div, div.linkwithin_img_18,
.linkwithin_img_19 div, div.linkwithin_img_19,
.linkwithin_img_20 div, div.linkwithin_img_20 {
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
border-radius: 100px;

}
.linkwithin_title {
color: #242424 !important; /* Color for titles */
font-family: Cambria,Georgia,sans-serif;
font-size: 12px !important; /* Font size of posts titles */
line-height: 24px !important;
text-align:center;
text-decoration: none;
}
.linkwithin_title:hover {
color: #000 !important; /* Color of posts titles on mouseover */
}
After adding this CSS, the LinkWithin gadget will look like this:

linkwithin gadget, related posts widget, blogger widgets

If you don't want round thumbnails, remove the code in red. In green you can see the parts which can be customized - there you can apply more styles or change the background color, text size, etc.

After you've made the changes, click on the "Save Template" button. So this is how we can customize the LinkWithin related posts widget. Enjoy!

Setting up Google Analytics for a 2nd or later blog

This article is about how to set up Google Anaytics to work on subsequent Blogger sites, if you have already set it up for your first blog or website.




If you already have Google Analytics set up, then the process is a little different to setting it up for your first blog (which is nicely described by GreenLava over on BloggerSentral) - because you already have a Google Analytics account, which you must add a new web property to.

How to set up Google Analytics for a subsequent blog



Log into Analytics using the Google Account which you use for Analytics overall (ie which you used for your other blogs or websites).


Choose the Admin tab  (currently linked from near the right on the orange menu bar)


From the drop-menu under Property, choose Create a New Property




Choose Website (it's the default)


Choose whether to use Universal Analytics (currently still beta) or Classic Analytics.
(I've chosen Universal for the blog that I've just set up - will be interesting to see how it's different from classic for blogger).


Enter the
  • Sitename
  • Blog's URL
  • Industry category


Choose the Reporting Timezone:  I've left it on US / Pacific, because that's what my other blogs are based on.


Click Get Tracking ID.    The page that shows has your Tracking ID, it's like this (where the n's and m's are numbers):

      UA-100nnnnn-mm


  • nnnnnnn is your own number, identifying your account.
  • mm is the number of this analytics property - it is what makes your property ID unique.



Log in to Bogger using an account which has Administrator rights for the blog.


Put this Tracking ID into the    Settings > Other > Google Analytics >  Google Analytics Web Property ID  field.  


Click Save settings.


Wait 24 hours or so, for the code to activate.    If you're not seeing statistics after that, check if your blog really is getting visits (eg visit it yourself a couple of times)  - and ask for assistance in the Blogger Product forum.


Do you have Adsense on more than one site, including this one?

If you have AdSense on more than one website, and you are going to have it on this site, then you need to take some extra steps so that Analytics gets the AdSense data.    See here for more information.


Do you need to install the tracking code?

As well as your trackingID, Analytics also shows a block of code, with this header:
This is your tracking code. Copy and paste it into the code of every page you want to track.

The good news for Blogger users with newer Dynamic or Designer templates is that we can ignore this:   Blogger puts the code in for us.

But if you're using an older Layout or Classic template, or a Designer template that's older, you may need to install some code (not the Analytics tracking code, though) manually.

If you'e in doubt, edit your template in the usual way, and search for:
<b:include name='google-analytics' data='blog'/>
If you can find it, then do nothing, your blog already has the code you need, and your statistics should start flowing soon.

If you cannot find that line, then add it, just before the </body> tag.  (Search for   </body   and paste just before it).

Either way - don't install the tracking code from Analytics, because as Blogger operates now, this will not correctly count visits from mobile devices.



Related Articles:

How to edit your Blogger template

Using Google Analytics if you have AdSense on multiple websites.

Understanding Google accounts

Friday, 7 February 2014

Advanced Random posts widget for Blogger with image thumbnails and snippets

When your blog has too many posts, visitors don't always have the time or desire to go through all the posts written there in order to make an idea of the blog's content. Thus, a random posts widget that will allow visitors to find content more easily could be really useful. This tutorial will show you how to add a random posts widget to display a list of posts in a random order with thumbnails and excerpts.

random posts widget for blogger



Adding Random Posts with Thumbnails and Posts Summary on Blogger

Step 1. Login to your blogger account, select your blog and go to "Layout".

Step 2. Add new widget by clicking on the "Add a gadget" link and select "Html/JavaScript" from the popup window.
html javascript widget, blogger gadgets

Step 3. After adding the HTML/JavaScript, copy and paste the following script inside the empty Content box.
<style>
#random-posts img {
    border-radius: 10px;
    float: left;
    margin-right: 5px;
    width: 75px;
    height: 75px;
    background-color: #F5F5F5;
    padding: 3px;
    transition: all 0.2s linear 0s;
}

#random-posts img:hover {
    opacity: 0.6;
}

ul#random-posts {
    list-style-type: none;
    padding: 0px;
}

#random-posts a {
    font-size: 12px;
    text-transform: uppercase;
    padding: 0px auto 5px;
}

#random-posts a:hover {
    text-decoration: none;
}

.random-summary {
    font-size: 11px;
    background: none;
    padding: 5px;
    margin-right: 8px;
}

#random-posts li {
    margin-bottom: 10px;
    border-bottom: 1px solid #EEEEEE;
    padding: 4px;
}
</style>
<ul id='random-posts'>
<script type='text/javaScript'>
var randomposts_number = 5;
var randomposts_chars = 110;
var randomposts_details = 'yes';
var randomposts_comments = 'Comments';
var randomposts_commentsd = 'Comments Disabled';
var randomposts_current = [];
var total_randomposts = 0;
var randomposts_current = new Array(randomposts_number);

function randomposts(json) {
    total_randomposts = json.feed.openSearch$totalResults.$t
}
document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=randomposts\"><\/script>');

function getvalue() {
    for (var i = 0; i < randomposts_number; i++) {
        var found = false;
        var rndValue = get_random();
        for (var j = 0; j < randomposts_current.length; j++) {
            if (randomposts_current[j] == rndValue) {
                found = true;
                break
            }
        };
        if (found) {
            i--
        } else {
            randomposts_current[i] = rndValue
        }
    }
};

function get_random() {
    var ranNum = 1 + Math.round(Math.random() * (total_randomposts - 1));
    return ranNum
};
</script>
<script type='text/javaScript'>
function random_posts(json) {
    for (var i = 0; i < randomposts_number; i++) {
        var entry = json.feed.entry[i];
        var randompoststitle = entry.title.$t;
        if ('content' in entry) {
            var randompostsnippet = entry.content.$t
        } else {
            if ('summary' in entry) {
                var randompostsnippet = entry.summary.$t
            } else {
                var randompostsnippet = "";
            }
        };
        randompostsnippet = randompostsnippet.replace(/<[^>]*>/g, "");
        if (randompostsnippet.length < randomposts_chars) {
            var randomposts_snippet = randompostsnippet
        } else {
            randompostsnippet = randompostsnippet.substring(0, randomposts_chars);
            var whitespace = randompostsnippet.lastIndexOf(" ");
            randomposts_snippet = randompostsnippet.substring(0, whitespace) + "&#133;";
        };
        for (var j = 0; j < entry.link.length; j++) {
            if ('thr$total' in entry) {
                var randomposts_commentsnum = entry.thr$total.$t + ' ' + randomposts_comments
            } else {
                randomposts_commentsnum = randomposts_commentsd
            }; if (entry.link[j].rel == 'alternate') {
                var randompostsurl = entry.link[j].href;
                var randomposts_date = entry.published.$t;
                if ('media$thumbnail' in entry) {
                    var randompoststhumb = entry.media$thumbnail.url
                } else {
                    randompoststhumb = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR2bMmH85yjxR6WYQiOFkDC1Eebws0L74hgGS-6h0r2KCSIrid40A4OJgnNoym6vU8yi-3zxRftySJB_hvz14ViNbS79KDE-DdUw2tk8b-y8Sjd_6VPgOwvoWAbZp9hfPz0bTnQ-06vlM/s1600/no_thumb.png"
                }
            }
        };
        document.write('<li>');
        document.write('<a href="' + randompostsurl + '" rel="nofollow"><img alt="' + randompoststitle + '" src="' + randompoststhumb + '"/></a>');
        document.write('<div><a href="' + randompostsurl + '" rel="nofollow">' + randompoststitle + '</a></div>');
        if (randomposts_details == 'yes') {
            document.write('<span><div  class="random-info">' + randomposts_date.substring(8, 10) + '.' + randomposts_date.substring(5, 7) + '.' + randomposts_date.substring(0, 4) + ' - ' + randomposts_commentsnum) + '</div></span>'
        };
        document.write('<br/><div class="random-summary">' + randomposts_snippet + '</div><div style="clear:both"></div></li>')
    }
};
getvalue();
for (var i = 0; i < randomposts_number; i++) {
    document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index=' + randomposts_current[i] + '&max-results=1&callback=random_posts\"><\/script>')
};
</script>
</ul>

Random Posts Options

  • Thumbnail dimensions: to change the size of the thumbnails in pixels, replace the 75px value.
  • Summary length: you can control the the length of the summary (in characters) by changing the 110 value from var randomposts_chars=110;
  • Post info: if you want to hide the post date and comment count change 'yes' from var randomposts_details='yes'; to 'no';
  • Font Size for Posts Titles and Summary: to modify the font size for the post snippet modify the 11px value and for the posts title, the 12px value;
Click on the "Save" button and View your blog. The sidebar will display a random posts widget on each of your blog pages.