Monday, June 26, 2006

The Quick and Dirty Way to Expandable Blogger Posts without Javascript!

When I was making that post with my Updated Photo Gallery I didn't want all the pictures to show up on the main page. For slower connections it would take a while to load, which would be a hassle for people who don't feel like looking at pictures of my summer vacations.

Finding code for expandable posts was hard for me. I knew Clay had cracked the code, but this was something I had to do for myself.

First I looked in the Blogger help section. They've got show/hide post code and post summary code there. I was looking for the second one, but I didn't want the "Read more" text at the bottom of each post.

All the places I found on the Schminternet involve including even more Javascript onto your template. That's great for people who love scripts, but as andy so helpfully pointed out, I have enough scripts as it is. Then, I found the "holy grail" (no, not that one, Dan Brown.)

Here's the secret code. You have to have post pages enabled for this to work. Put the following code in your template somewhere between the <style> </style> tags. It's the only change you need to make to your template.

<MainOrArchivePage>
span.fullpost {display:none;}
</MainOrArchivePage>

<ItemPage>
span.fullpost {display:inline;}
</ItemPage>

In your post, put what you want hidden between <span class="fullpost"> </span> Then, after you post it, find out the address of the post page. (It's usually something like http://your blog.blogspot.com/year/month/name of post here.html)

Copy that URL and go back to edit the post you want expanded. Edit the post, create an html link to the post page before the <span class="fullpost">. People usually write something like "click here to expand this post" or "read more" or "Sheeyahhh! Expandable posts baby!"

That's it! Yay! It's not elegant but it works, and that's all that really matters.

If you do want those more elegant, javascript-filled hacks, check out these links.
http://nerdierthanthou.nfshost.com/2004/10/i-did-it.html
http://chublogga.blogspot.com/2004/10/adding-showhide-extended-post.html
http://www.meghalomania.com/expand-collapse-script-for-blogger-blogs/


Addendum: Now that Blogger has changed how people edit their templates, I'm not sure if this will work anymore. I haven't tried it, so if anyone finds this page looking for Blogger expandable post info, use the code at your own risk!

8 comments:

Unknown said...

Pretty darn cool, your html is going way well!

Princess Blogonoke said...

It goes even better when I put the right link in my expandable post link.

All fixed now though! Hurray hurray! Laura = not clumsy at all... yeah.

Anonymous said...

Hooray, my baby is larning how to program dem 'puters. Pretty soon she'll be laying down some C and Perl like n0body's business.

Claytonian said...

I would say that's simpler than what I did.

Anonymous said...

andy sez:

F**K C.

Princess Blogonoke said...

andy only says that because he and C used to be really close, then C dumped him for Pascal and stole all of his CD's.

I hear C and Pascal have a baby named LIMBO now. Their marriage is a sham though. They only stay together for the child.

Anonymous said...

andy sez:

I read this while an actual grad student named Pascal was in the office. Awkward.

Princess Blogonoke said...

Bwahahahahaha!

BWAHAHAHAHAAHAHAHA!

Hilarious.