Blogger Hacks, Categories, Tips & Tricks

Wednesday, July 27, 2005
Drop-down menu for Recent Posts
Alright, I promise I haven't gone completely drop-down crazy... Well maybe just a little....

Here's the code to turn your "recent posts" display in your blogspot blog into a drop-down menu.

<p style="text-align: center">
<select name="PreviousItemsMenu" onChange="location.href=this.options[this.selectedIndex].value;">
<option value="/">- Recent Posts -</option>
<BloggerPreviousItems>
<option value="<$BlogItemPermalinkURL$>"><$BlogPreviousItemTitle$></option>
</BloggerPreviousItems>
</select>
</p>

I modified Li Zhao's code for the archive drop-down to work with the "10 most recent posts" display in blogger. Let me know if it works for you.

I used centricle to convert the code so that it would display in this post. Thanks to Improbulus for the tip.

See other posts in Blogger Hacks: The Series

Posted at 9:18 AM by John.
19 Comments:
<    >
Blogger Improbulus said...
Thanks for the mention and the link, John - glad it was of use.

And this is a great tip from you too, shall give it a go!

<    >
Blogger Unknown said...
Did you see that del.icio.us is supporting a JavaScript "linkroll" that lists recent posts?
http://del.icio.us/doc/feeds/js
I'm considering trying it, although I really like your idea of using drop-down menus for categories, archives, and possibly recent posts. I haven't decided whether or not to implement any of those, but rest assured I'll give you due credit... :-)

<    >
Blogger Sarebear said...
Hi. What if the titles of my previous posts are too long for the sidebar? Is there an option to have it wrap it in the drop down, or just put the first say 20 characters or whatnot?

<    >
Blogger Kurt Beard said...
Using an RSS feed you can have drop-down menu for other's blogs. You need to run the RSS feed thourgh http://jade.mcli.dist.maricopa.edu/feed/. The end result works well; I am using it at http://delayedepiphany.blogspot.com/

<    >
Blogger Attila said...
Is there any way to adjust this code to make it work on permalinked posts? You know, get it to appear below or next to the "<< Home" link? People show up through a permalink, and I'd like them to see what I've been writing recently.

<    >
Blogger Claire said...
This is cool. I tweaked it a little so that it would let me adjust the colors like the reverse archive drop down code does.

Now if I can just figure out how to make the two menus the same width.

<    >
Blogger Yash said...
hey i`d like the answer for what atila asked too. Is it possible to display drop-down menu of recent posts on the "post page" the permalink page of the post? I have used it on my template at http://cartoonsne1.blogspot.com but when i click the permalink of a post, the recent posts again displays as a list instead of a drop down

<    >
Anonymous Anonymous said...
This will probably sound like the stupidest thing in the world, but where do I put it? Because I've tried putting it where I think it should go.. and it works.. but my sidebar is at the BOTTOM of my page. Help!!

<    >
Blogger John said...
Anon,

You can put it wherever you like. As a straight swap-out, it should replace the bloggerprevous items tags.... You can comment them out, insert the new code, and preview your page so that the changes aren't irreversible. It can go anywhere you like, though, so experiment 'til it looks good w/ your template!

<    >
Blogger Triet said...
looks good, but when I inserted it, I found that following it to a previous post brought me to a post page without my archive list in the sidebar. Here's my blog:

The Bleeding Ear

Any ideas?

<    >
Blogger Lucas said...
Yeah, that worked awesome in the three templates I used it for :) thanks.

<    >
Anonymous Anonymous said...
used your previous posts hack in my blog. ^_^ great! ^_^

<    >
Blogger Unknown said...
hi Everybody.

has anybody figured out how to change the text length in the drop down menu, so that it can be shortened in teh drop down menu?

emailing me at BlogsoupATgmailDOTCOM would be great.

thank you in advance for any help you might have.

<    >
Blogger Breena Ronan said...
Looks great, but it's too wide for my sidebar!

<    >
Blogger John said...
You can use CSS in your template head to style it. I had to use multiple lines.... 1 controlled the menu, & the other fixed the blogger nav-bar that went crazy when I added the line for the menu! Thanks to input from Greg, Singpolyma, and others, the relevant css in my template head looks like this:

select { width: 10em; }
input[type='submit'] { width:auto; }
input[type='button'] { width:auto; }
input { width: 10em; }
input[type='image'] { width:auto; }

<    >
Blogger Hannes Couvreur said...
John,

I inserted the code and it works perfectly.

At least for Firefox. For IE the dropdownmenu doesn't expand when clicked on so it is impossible to read the longer post-titles.

Anyone a sollution? (besides adding a button "best viewed in Firefox")

Arne.

<    >
Blogger Tahoma Activist said...
I've also put this hack into my sidebar, although it's way too wide. Anyone know how to fix it so it doesn't look out of place?

Here's a link to my blog so you can see what I mean.

<    >
Blogger John said...
Tahoma,

It will default to accomodate your longest post title. You can use CSS to limit the size of the unselected box. See Stephen's comment on Freshblog.

<    >
Blogger John said...
Or my comment, of course!


eXTReMe Tracker