Tag: programming

Blogger.com Template Tip Part 2: Render Previous Post Links

by on Dec.13, 2006, under Posts

Enhancing on the previous session of Blogger.com template goodies, I’ve finetuned the behaviour of the “Previous Post/Month” link at the bottom of three types of blog pages. The common tip that other bloggers use to display the previous post’s link will not work well in the individual post pages, thus the need to enhance using JavaScript here. They are:

  1. MainPage – display link to the n + 1 page, where n is the number of posts to display per page
  2. ItemPage – display link to the previous post
  3. ArchivePage – display select combobox with all months of posts

You may want to read up on the previous session first before proceeding below.

Place this (updated) JavaScript code anywhere in between your template’s tag. Same thing, adjust nMaxPostsOnMainPage to the number of posts that you have set to display.

Main Page

Use the JavaScript function writePrevPostOnMainPage() as before, on the main page. You can use something like:

Previous post:

Item Page

For individual posts, use the following code. You can place this just next to the preceding code of the tags.

Previous post:

Archive Page

This last part may be no surprise to some of you as you may have seen a variant of this elsewhere. Place this code next to the preceding code:

” target=”_top”>Back to Home |
Other Months:

Same your template, publish, and test these goodies out!

If you try all these code, please let me know how it goes for you. Leave comments here…

Related posts:

Blogger.com Template Tip: Render Previous Post Link At Bottom Of Main Page
http://glob.lokety.com/2006/11/bloggercom-template-tip-render.html>

Technorati Tags: , , , , , , , , ,

Share
Leave a Comment :, , more...

Blogger.com Template Tip: Render Previous Post Link At Bottom Of Main Page

by on Nov.07, 2006, under Posts

More experienced bloggers using Blogger.com have been able to put “previous” links to lead visitors to the previous post of their blog. On the main page, there is a fixed number of posts that you can choose to display, usually 3. Some visitors may be reading your main page from top to bottom. Now, besides having to refer to the list of previous posts in the sidebar, how can you provide a link at the end of last post of this main page for the visitors to continue reading?

I have written a bit of JavaScript and Blogger.com code just for this. You just need to copy the following code in the right places of your template and it will render a link to the previous post after the fixed number of posts on the main page.

Copy this chunk to the <head> section, preferably after the bunch of <meta> tags. Replace the number “3” in the line that contains “nMaxPostsOnMainPage” to the fixed number of posts on your main page, if it is not 3.

Place this line just after the </Blogger> tag near the line that has the HTML comment “End #main”. If you want to apply any CSS style to the line, specify it in the <div> tag.

Previous post:

Save the template and publish your site. It should work now.

Note: avoid using “|” in the title of your posts as it is used programmatically in my code.

I can probably expand this code to:

  • display a specified number of previous posts, instead of just one
  • display a dropdown list of previous posts to quickly jump to any post

If you find this Blogger.com template tip useful, please link back to me using this permalink. Thanks!

Update (December 13 2006): I’ve made some enhancements to this stuff. Click here to see the next post.

Technorati Tags: , , , , , , ,

Share
Leave a Comment :, more...