Showing posts with label H - Foot. Show all posts
Showing posts with label H - Foot. Show all posts

Saturday, June 27, 2009

Customizing Blogger post Navigation script





Blogger Blogs have default post navigation script which allows user to navigate between posts.It consists of ” older posts” , “Newer posts” and ” Home page” link. Since it’s default , no CSS codings are added for the navigation script. So in this post I will explain how to modify the script and to add background images and then aligning the older posts and newer posts links properly.



Know the script codes


Before explaining how to customize the codes , I would like to explain the tags involved in the blogger templates which control the blogger post navigation script.




CSS codes


Firstly, let us see the default code included in minima or Rounders blogger template.


#blog-pager-newer-link {

float: $startSide;

margin-$startSide: 13px;

}

#blog-pager-older-link {

float: $endSide;

margin-$endSide: 13px;


}


#blog-pager {

text-align: center;

}


instead of startside and endside we can have left and right respectively.

#blog-pager-newer-link : this code contains the css necessary for newer posts link

#blog-pager-older-link : this code contains the css necessary for older posts link

and #blog-pager controls the contains necessary for Home page links.


If you are using custom blogger template , then you will find something like this :


#blog-pager-newer-link {

padding-left : 20px;

border : none;

float : left;

}

#blog-pager-older-link {

float : right;

padding-right : 20px;

border : none;


}

#blog-pager {

padding : 0 15px 0;

text-align : center;

}

.blog-pager a {

color : #cc0000;

}

.blog-pager a:hover {


color : #cc0000;

}



XML tags which shows the post navigation links


Now let us see the default tags included in the blogger templates which shows post navigation links.To see this tag , you need to check ” expand widget templates” option in EDIT HTML page of the blogger template.


There you can find the following tag


<b:includable id=’nextprev’>

<div class=’blog-pager’ id=’blog-pager’>

<b:if cond=’data:newerPageUrl’>


<span id=’blog-pager-newer-link’>

<a class=’blog-pager-newer-link’ expr:href=’data:newerPageUrl’ expr:id=’data:widget.instanceId + &quot;_blog-pager-newer-link&quot;’ expr:title=’data:newerPageTitle’><data:newerPageTitle/></a>

</span>

</b:if>

<b:if cond=’data:olderPageUrl’>

<span id=’blog-pager-older-link’>

<a class=’blog-pager-older-link’ expr:href=’data:olderPageUrl’ expr:id=’data:widget.instanceId + &quot;_blog-pager-older-link&quot;’ expr:title=’data:olderPageTitle’><data:olderPageTitle/></a>


</span>

</b:if>


<b:if cond=’data:blog.homepageUrl != data:blog.url’>

<a class=’home-link’ expr:href=’data:blog.homepageUrl’><data:homeMsg/></a>

<b:else/>

<b:if cond=’data:newerPageUrl’>

<a class=’home-link’ expr:href=’data:blog.homepageUrl’><data:homeMsg/></a>


</b:if>

</b:if>


</div>

<div class=’clear’/>

</b:includable>


As mentioned in the CSS codes itself,



  • <b:if cond=’data:newerPageUrl’> contains the code to show newer post links.


  • <b:if cond=’data:olderPageUrl’> contains the code necessary to show older posts link.

  • <b:if cond=’data:blog.homepageUrl != data:blog.url’> will contain the code necessary to show Home Page Link.


Hope now you know about the code which controls the Older post and Newer post links for post navigation. Now let us see how to customize this script to suit our blogger template.



Adding background image along with text


Let us see how to add Background image to the text Older Posts and Newer Posts.


Go to EDIT HTML SUBTAB and then search this following code or similar.


#blog-pager-newer-link {

float: $startSide;

margin-$startSide: 13px;

}

#blog-pager-older-link {

float: $endSide;

margin-$endSide: 13px;

}



#blog-pager {

text-align: center;

}


Now replace the whole code with



#blog-pager-newer-link {

background : url(http://i43.tinypic.com/11bro1s.jpg) no-repeat left 0%;

padding-left : 20px;

border : none;


float : left;

}

#blog-pager-older-link {

float : right;

background : url(http://i44.tinypic.com/2n6dirp.jpg) no-repeat right 0%;

padding-right : 20px;

border : none;

}

#blog-pager {


padding : 0 15px 0;

text-align : center;

}

.blog-pager a {

color : #cc0000;

}

.blog-pager a:hover {

color : #cc0000;

}


In that you can change the background images and then customize the color of the text. That’s it now save your template , you can find something like this :

post navigation image



Replace Image with Background images


To replace the “older posts” , ” Newer Posts” and “Home” text with background images , follow these simple steps.


replace the css code for blog post navigation widget with this code



#blog-pager-newer-link {

padding-left : 20px;

border : none;


float : left;

}

#blog-pager-older-link {

float : right;

padding-right : 20px;

border : none;

}

#blog-pager{

padding:50px 10px 10px 10px;


text-align:center;

}

.blog-pager a{

color:#A10000

}

.blog-pager a:hover{

color:#15FFED

}


and then save your template. Now check ” Expand Widget Templates” option and now replace the



<b:includable id=’nextprev’>

<div class=’blog-pager’ id=’blog-pager’>

<b:if cond=’data:newerPageUrl’>

<span id=’blog-pager-newer-link’>

<a class=’blog-pager-newer-link’ expr:href=’data:newerPageUrl’ expr:id=’data:widget.instanceId + &quot;_blog-pager-newer-link&quot;’ expr:title=’data:newerPageTitle’><data:newerPageTitle/></a>

</span>

</b:if>

<b:if cond=’data:olderPageUrl’>

<span id=’blog-pager-older-link’>

<a class=’blog-pager-older-link’ expr:href=’data:olderPageUrl’ expr:id=’data:widget.instanceId + &quot;_blog-pager-older-link&quot;’ expr:title=’data:olderPageTitle’><data:olderPageTitle/></a>

</span>

</b:if>


<b:if cond=’data:blog.homepageUrl != data:blog.url’>

<a class=’home-link’ expr:href=’data:blog.homepageUrl’><data:homeMsg/></a>


<b:else/>

<b:if cond=’data:newerPageUrl’>

<a class=’home-link’ expr:href=’data:blog.homepageUrl’><data:homeMsg/></a>

</b:if>

</b:if>


</div>

<div class=’clear’/>

</b:includable>



with this code


<b:includable id=’nextprev’>

<div class=’blog-pager’ id=’blog-pager’>

<b:if cond=’data:newerPageUrl’>

<span id=’blog-pager-newer-link’>

<a class=’blog-pager-newer-link’ expr:href=’data:newerPageUrl’ expr:id=’data:widget.instanceId + &quot;_blog-pager-newer-link&quot;’ expr:title=’data:newerPageTitle’><img alt=’techieblogger.com’ src=’http://i69.photobucket.com/albums/i42/queenofdreamsz/NextIcon.gif’ title=’Newer Post’/></a>


</span>

</b:if>

<b:if cond=’data:olderPageUrl’>

<span id=’blog-pager-older-link’>

<a class=’blog-pager-older-link’ expr:href=’data:olderPageUrl’ expr:id=’data:widget.instanceId + &quot;_blog-pager-older-link&quot;’ expr:title=’data:olderPageTitle’><img alt=’Techie Blogger’ src=’http://i69.photobucket.com/albums/i42/queenofdreamsz/BackIcon.gif’ title=’Older Post’/></a>


</span>

</b:if>


<b:if cond=’data:blog.homepageUrl != data:blog.url’>

<a class=’home-link’ expr:href=’data:blog.homepageUrl’><img alt=’Techie Blogger’ src=’http://i85.photobucket.com/albums/k47/bongmalove/icon/home.gif’ title=’Home Page’/></a>

<b:else/>


<b:if cond=’data:newerPageUrl’>

<a class=’home-link’ expr:href=’data:blog.homepageUrl’><img alt=’Techie Blogger’ src=’http://i85.photobucket.com/albums/k47/bongmalove/icon/home.gif’ title=’Home Page’/></a>

</b:if>

</b:if>


</div>


<div class=’clear’/>

</b:includable>


You can change the images included with your own blog navigation images. After that save your template and check your blog. You can find a blog navigation links something like this :



post navigation


Show blog post navigation above posts title


You can also show the blog post navigation script above post title too. In order to implement this hack , go to EDIT HTML page of your blog and check ” EXPAND WIDGET TEMPLATES” option. Now search this tag in your template.



  • <b:includable id=’main’ var=’top’>



Now paste the following code immediately below it




  • <b:include name=’nextprev’/>



Troubleshooting problems with blog post navigation script


Few might have noticed that the Blog post navigation links will be misaligned sometimes. Newer post , Older post and Home page links will get together. So it means that the CSS codes are missing for the file. To overcome this problem , just copy and paste the corresponding CSS code you need above ]]></b:skin> .


Blog post navigation missing



Sometimes the blog post navigation may be missing in your blog. It’s because the blog post navigation code may be missing in your template. To overcome this problem , search this tag in your template with ” expand widget templates” option enabled.


<b:include name=’nextprev’/>


if the tag is missing , then add the above tag in your template below <b:includable id=’main’ var=’top’> as shown in the image.


troubleshooting Customizing Blogger post Navigation script


Hope this post will be helpful for all blogger newbies. If you need any other customization then feel free to ask in comment form below.


Popularity: 7%


Read more!

Sunday, October 12, 2008

Page Navigation Hack for Blogger

Most said page navigation menu in the bottom of the page can appear only in Wordpress blogs. But Now here is a blogger hack which will help you to show Page Navigation Menu in bottom of the page ( see screenshot ) . you can Add this Page Navigation hack to your blogger template either by inserting script to your template by editing or you can add it as a widget . In this post I will write only how to add this Page navigation menu by editing template code.


I have used a background image for this Page Navigation hack. If you want to show this without the background image just remove the background image url .

Let us start :
Step
1

: Log in to your blogger account and navigate to Layout section. Now go to the edit HTML subtab.

Step
2

: search this line ]]></b:skin> and add this CSS code above that line.

CSS CODE WITH IMAGE :

.showpageArea {padding: 10px; color:#003366;text-align:left;width:530px;
}
.showpageArea a {float:left;
background:url(http://i263.photobucket.com/albums/ii150/mohamedrias/backbutton.gif) no-repeat 0 0;
text-align:center;width:127px;
height:42px;
text-align:center;
display:block;margin:0 5px;
color:#333;
padding-top:6px;
}
.showpageArea a:hover {
color:#333;
margin:0 5px;
padding-top:6px;
}
.showpageNum a {background:url(http://i263.photobucket.com/albums/ii150/mohamedrias/page_num.gif) no-repeat 0 0;
width:37px;
height:42px;
display:block;
text-align:center;
float:left;
margin:0 5px;
padding-top:6px;
text-decoration:none;
color:#333;
}
.showpageNum a:hover { background:url(http://i263.photobucket.com/albums/ii150/mohamedrias/page_num.gif) no-repeat 0 100%;
color:#FFF;
}
.showpagePoint {background:url(http://i263.photobucket.com/albums/ii150/mohamedrias/page_num.gif) no-repeat 0 100%;
width:37px;
height:42px;
display:block;
float:left;
text-align:center;
margin:0 5px;
padding-top:6px;
font-weight:bold;
color:#FFF;
}
.showpage a {
}
.showpage a:hover {
}
.showpageNum a:link,.showpage a:link {
text-decoration:none;
color:#cc0000;
}

It must look like this :



Step
3

: Now search for this code or related in your template ( no need to expand widgets )

<b:section class='main' id='main' showaddelement='yes'>
<b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'/>
</b:section>


Now Add This script just below the </b:section> .
&lt;script type=&quot;text/javascript&quot;&gt;

function showpageCount(json) {
var thisUrl = location.href;
var htmlMap = new Array();
var isFirstPage = thisUrl.substring(thisUrl.length-14,thisUrl.length)==&quot;.blogspot.com/&quot;;
var isLablePage = thisUrl.indexOf(&quot;/search/label/&quot;)!=-1;
var isPage = thisUrl.indexOf(&quot;/search?updated&quot;)!=-1;
var thisLable = isLablePage ? thisUrl.substr(thisUrl.indexOf(&quot;/search/label/&quot;)+14,thisUrl.length) : &quot;&quot;;
thisLable = thisLable.indexOf(&quot;?&quot;)!=-1 ? thisLable.substr(0,thisLable.indexOf(&quot;?&quot;)) : thisLable;
var thisNum = 1;
var postNum=1;
var itemCount = 0;
var fFlag = 0;
var eFlag = 0;
var html= &#39;&#39;;
var upPageHtml =&#39;&#39;;
var downPageHtml =&#39;&#39;;

var pageCount=5;
var displayPageNum=3;
var firstPageWord = &#39;First&#39;;
var endPageWord = &#39;Last&#39;;
var upPageWord =&#39;Previous&#39;;
var downPageWord =&#39;Next&#39;;

var labelHtml = &#39;&lt;span class=&quot;showpageNum&quot;&gt;&lt;a href=&quot;/search/label/&#39;+thisLable+&#39;?&amp;max-results=&#39;+pageCount+&#39;&quot;&gt;&#39;;

for(var i=0, post; post = json.feed.entry[i]; i++) {
var timestamp = post.published.$t.substr(0,10);
var title = post.title.$t;
if(isLablePage){
if(title!=&#39;&#39;){
if(post.category){
for(var c=0, post_category; post_category = post.category[c]; c++) {
if(encodeURIComponent(post_category.term)==thisLable){
if(itemCount==0 || (itemCount % pageCount ==(pageCount-1))){
if(thisUrl.indexOf(timestamp)!=-1 ){
thisNum = postNum;
}

postNum++;
htmlMap[htmlMap.length] = &#39;/search/label/&#39;+thisLable+&#39;?updated-max=&#39;+timestamp+&#39;T00%3A00%3A00%2B08%3A00&amp;max-results=&#39;+pageCount;
}
}
}
}//end if(post.category){

itemCount++;
}

}else{
if(title!=&#39;&#39;){
if(itemCount==0 || (itemCount % pageCount ==(pageCount-1))){
if(thisUrl.indexOf(timestamp)!=-1 ){
thisNum = postNum;
}

if(title!=&#39;&#39;) postNum++;
htmlMap[htmlMap.length] = &#39;/search?updated-max=&#39;+timestamp+&#39;T00%3A00%3A00%2B08%3A00&amp;max-results=&#39;+pageCount;
}
}
itemCount++;
}
}

for(var p =0;p&lt; htmlMap.length;p++){
if(p&gt;=(thisNum-displayPageNum-1) &amp;&amp; p&lt;(thisNum+displayPageNum)){
if(fFlag ==0 &amp;&amp; p == thisNum-2){
if(thisNum==2){
if(isLablePage){
upPageHtml = labelHtml + upPageWord +&#39;&lt;/a&gt;&lt;/span&gt;&#39;;
}else{
upPageHtml = &#39;&lt;span class=&quot;showpage&quot;&gt;&lt;a href=&quot;/&quot;&gt;&#39;+ upPageWord +&#39;&lt;/a&gt;&lt;/span&gt;&#39;;
}
}else{
upPageHtml = &#39;&lt;span class=&quot;showpage&quot;&gt;&lt;a href=&quot;&#39;+htmlMap[p]+&#39;&quot;&gt;&#39;+ upPageWord +&#39;&lt;/a&gt;&lt;/span&gt;&#39;;
}

fFlag++;
}

if(p==(thisNum-1)){
html += &#39;&amp;nbsp;&lt;span class=&quot;showpagePoint&quot;&gt;&lt;u&gt;&#39;+thisNum+&#39;&lt;/u&gt;&lt;/span&gt;&#39;;
}else{
if(p==0){
if(isLablePage){
html = labelHtml+&#39;1&lt;/a&gt;&lt;/span&gt;&#39;;
}else{
html += &#39;&lt;span class=&quot;showpageNum&quot;&gt;&lt;a href=&quot;/&quot;&gt;1&lt;/a&gt;&lt;/span&gt;&#39;;
}
}else{
html += &#39;&lt;span class=&quot;showpageNum&quot;&gt;&lt;a href=&quot;&#39;+htmlMap[p]+&#39;&quot;&gt;&#39;+ (p+1) +&#39; &lt;/a&gt;&lt;/span&gt;&#39;;
}
}

if(eFlag ==0 &amp;&amp; p == thisNum){
downPageHtml = &#39;&lt;span class=&quot;showpage&quot;&gt; &lt;a href=&quot;&#39;+htmlMap[p]+&#39;&quot;&gt;&#39;+ downPageWord +&#39;&lt;/a&gt;&lt;/span&gt;&#39;;
eFlag++;
}
}//end if(p&gt;=(thisNum-displayPageNum-1) &amp;&amp; p&lt;(thisNum+displayPageNum)){
}//end for(var p =0;p&lt; htmlMap.length;p++){

if(thisNum&gt;1){
if(!isLablePage){
html = &#39;&lt;span class=&quot;showpage&quot;&gt;&lt;a href=&quot;/&quot;&gt;&#39;+ firstPageWord +&#39; &lt;/a&gt;&lt;/span&gt;&#39;+upPageHtml+&#39; &#39;+html +&#39; &#39;;
}else{
html = &#39;&#39;+labelHtml + firstPageWord +&#39; &lt;/a&gt;&lt;/span&gt;&#39;+upPageHtml+&#39; &#39;+html +&#39; &#39;;
}
}

html = &#39;&lt;div class=&quot;showpageArea&quot;&gt;&lt;span style=&quot;font-size:11px;padding: 2px 4px 2px 4px;margin: 2px 2px 2px 2px;color: #000000;border: 1px solid #333; background-color: #FFFFFF;&quot; class=&quot;showpage&quot;&gt;Page &#39;+thisNum+&#39; of &#39;+(postNum-1)+&#39;: &lt;/span&gt;&#39;+html;

if(thisNum&lt;(postNum-1)){
html += downPageHtml;
html += &#39;&lt;span class=&quot;showpage&quot;&gt;&lt;a href=&quot;&#39;+htmlMap[htmlMap.length-1]+&#39;&quot;&gt; &#39;+endPageWord+&#39;&lt;/a&gt;&lt;/span&gt;&#39;;
}

if(postNum==1) postNum++;
html += &#39;&lt;/div&gt;&#39;;

if(isPage || isFirstPage || isLablePage){
var pageArea = document.getElementsByName(&quot;pageArea&quot;);
var blogPager = document.getElementById(&quot;blog-pager&quot;);

if(postNum &lt;= 2){
html =&#39;&#39;;
}

for(var p =0;p&lt; pageArea.length;p++){
pageArea[p].innerHTML = html;
}

if(pageArea&amp;&amp;pageArea.length&gt;0){
html =&#39;&#39;;
}

if(blogPager){
blogPager.innerHTML = html;
}
}

}
&lt;/script&gt;

&lt;script src=&quot;/feeds/posts/summary?alt=json-in-script&amp;callback=showpageCount&amp;max-results=99999&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

<div style='text-align:right;font-size:10px;color:000000;margin-top:15px;display:none;'> <a href='http://socheatk.blogspot.com/2008/10/page-navigation-hack-for-blogger.html'>Grab this Widget ~ Blogger Accessories</a></div>


In the code above you can edit the lines in red to your wish .

1 : var pageCount = 5;

The digit in red represents number of posts to be shown in single page. Change the digit to show as many pages you want.

for example :

In my blog I have put that value as 2 . In each page you can see only 2 posts .

2 : var displayPageNum = 3;

here the digit in red represents number of pages to be listed.

For example :

In my blog I have chosen 3 , then 3 pages will be shown.

That's it now we have added Page Navigation menu hack to our blog successfully .

That CSS code will suit almost all templates. Please don't remove the credit link.

I hope all of you will like this Page Navigation blogger hack . If you have any doubts please ask in comment section . Comments are most welcome , please give me your feedback about this blogger Hack.

Read more!

 

©2009 daily news | by TNB