1058 followers
Follow us on Twitter!
260 followers
Join us on Facebook!
Note: The postviews count wont change when you refresh the blog homepage but it will change only when you visit individual posts.Windows Reloded, Get Latest Blogger widgets
1. Create your Firebase Account
In order to gain access to a free database and be able to keep a backup of your postviews counter data, you must sign up for a free account at Firebase.Fill up the easy steps sensibly and then once your account has been activated, you must create your first Firebase database.
Windows Reloded, Get Latest Blogger widgets
2. Create a Firebase Database
You can create 2 firebases. At present just create one, we will guide you later in coming posts about amazing things you can play with this free service.- Towards the bottom right side of your account, you will find the following submit box.
2. Inside this box input your website name. In my case I inserted mybloggertricks and this generated the following firebase URL: https://mybloggertricks.firebaseio.com
3. Finally hit the create button and note down your firebase URL because we would need it later in this tutorial.
3. Installing Postviews Plugin
- Go To Blogger > Template
- Backup your template
- Click Edit HTML
- Tick the box "Expand widget Templates"
- Search for ]]></b:skin>
- Just above it paste the following CSS code:
Windows Reloded, Get Latest Blogger widgets
/*-------- Post Views ----------*/
#views-container {
width: 75px;
float: right;
}
#views-container {
width: 75px;
float: right;
}
.mbtloading {
background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3wO6EKi7xjRBl0Lqp1qxuHv5VjroZVSfm5ICbjmmdKIL_pzT3yUh6In3mPDscyCZJI2KD5pBa2mBRx4y26mp5fletzavr7Y8hLjvKM4_N6UjtZRe55WGCd8HgwMG7_Yp4aksrn5z0niby/s320/mbtloading.gif') no-repeat left center;
width: 16px;
height: 16px;
}
background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3wO6EKi7xjRBl0Lqp1qxuHv5VjroZVSfm5ICbjmmdKIL_pzT3yUh6In3mPDscyCZJI2KD5pBa2mBRx4y26mp5fletzavr7Y8hLjvKM4_N6UjtZRe55WGCd8HgwMG7_Yp4aksrn5z0niby/s320/mbtloading.gif') no-repeat left center;
width: 16px;
height: 16px;
}
.viewscount {
color: #EE5D06;
font: bold italic 14px arial;
}
float: right;Windows Reloded, Get Latest Blogger widgets
color: #EE5D06;
font: bold italic 14px arial;
}
.views-text {
float: left;
font: bold 12px arial;
color: #333;
}
float: left;
font: bold 12px arial;
color: #333;
}
.views-icon{
background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQc7kbMgrhSNhdwFkimjhAjI4p-pDVVeiS5rN4yepbCtUSDtzjWxTHnMQwZEdGhZPc-B5iLVRa2yjRAxOWFGW08FRtkbK5H7WJxo-1_BGdZBZZZQJk-_lBzJqvANSKY4wabim8aYr58AF5/s1600/postviews.png') no-repeat left;
border: 0px;
width: 16px;
height: 16px;
float: left;
padding: 0px 2px;
}
Customizations:background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQc7kbMgrhSNhdwFkimjhAjI4p-pDVVeiS5rN4yepbCtUSDtzjWxTHnMQwZEdGhZPc-B5iLVRa2yjRAxOWFGW08FRtkbK5H7WJxo-1_BGdZBZZZQJk-_lBzJqvANSKY4wabim8aYr58AF5/s1600/postviews.png') no-repeat left;
border: 0px;
display: block;Windows Reloded, Get Latest Blogger widgets
width: 16px;
height: 16px;
float: left;
padding: 0px 2px;
}
- To change the text color of the numeric count, edit #EE5D06
- To change the plugin alignment, change right to left.
<!-- Post Views Script by MBT -->
<script type='text/javascript'>
window.setTimeout(function() {
document.body.className = document.body.className.replace('loading', '');
}, 10);
</script>
<script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'/>
<script>
$.each($('a[name]'), function(i, e) {
var elem = $(e).parent().find('#postviews').addClass('mbtloading');
var blogStats = new Firebase("https://windowsreloded.firebaseio.com/pages/id/" + $(e).attr('name'));
blogStats.once('value', function(snapshot) {
var data = snapshot.val();
var isnew = false;
if(data == null) {
data= {};
data.value = 0;
data.url = window.location.href;
data.id = $(e).attr('name');
isnew = true;
}
elem.removeClass('mbtloading').text(data.value);
data.value++;
if(window.location.pathname!='/')
{
if(isnew)
blogStats.set(data);
else
blogStats.child('value').set(data.value);
}
});
});
Make this change:<script type='text/javascript'>
window.setTimeout(function() {
document.body.className = document.body.className.replace('loading', '');
}, 10);
</script>
<script src='https://cdn.firebase.com/v0/firebase.js' type='text/javascript'/>
<script>
$.each($('a[name]'), function(i, e) {
var elem = $(e).parent().find('#postviews').addClass('mbtloading');
var blogStats = new Firebase("https://windowsreloded.firebaseio.com/pages/id/" + $(e).attr('name'));
blogStats.once('value', function(snapshot) {
var data = snapshot.val();
var isnew = false;
if(data == null) {
data= {};
data.value = 0;
data.url = window.location.href;
data.id = $(e).attr('name');
isnew = true;
}
elem.removeClass('mbtloading').text(data.value);
data.value++;
if(window.location.pathname!='/')
{
if(isnew)
blogStats.set(data);
else
blogStats.child('value').set(data.value);
}
});
});
</script>Windows Reloded, Get Latest Blogger widgets
- Replace the highlighted brown line with your firebase URL (Step#2). Make sure you replace it correctly by taking care of forward slash (/)
Note: If you are finding multi occurrences of the same code then choose the first occurrence.
9. Just above it paste the following HTML,
You can replace views: with any text you like.
10. Hit save and you are all done!
Visit your blog and press F5 (refresh page) to see the counts dancing just perfectly! :)





0 comments: