Thursday, October 23, 2008

More expandable post summaries

I figured out how to come up with the effect of that cool hack where you click on a post title to reveal hidden content without the words "...Read more". It's actually very simple. Click on the post title to see my recipe.

First of all, you don't need a hack to expand a post by clicking on its title - you only need to make sure you have "Post pages" in Settings enabled, i.e. set to "Yes", which is actually blogger default. With that setting, blogger gives each post a separate, individual post page, which is displayed by clicking on the post title. It's only hiding a part of the post from the front page of your blog that requires a hack. The hack I've already installed from coderstalk does just that, and more: it truncates the post into a summary which shows on the blog front page, then searches for a label "more" on that post and, upon finding it, attaches the clickable words "...Read more" at the end of the summary. Clicking "...Read more" takes the reader from the post summary on the blog front page to the individual post page, where the full content of the post is displayed. (That's why you need to have "Post pages" in Settings enabled for this hack to work). Now if you don't include the label "more", the hack will only be able to execute its first step, i.e. truncate the post. It will not attach the words "...Read more" because it can't find the label. Et voilà! You will have a truncated post with hidden content revealed upon clicking on the post title.

So there's no additional hack to install - the first hack already gives you two options for abbreviating posts. The option with "...Read more" will suggest that the post was taking up too much of the front page, while the option without "...Read more" is better for hiding content some readers might prefer not to see: the post seems complete at first glance but it actually has hidden content which you can warn them about, telling them to proceed at their own risk by clicking on the post title. Both are cool. It is also very convenient that you can switch between the options only by means of applying or not applying a post label, rather than switching between post templates.

Note that if you skip the label "more", you won't be able to search for your expandable posts using that label. So you might want to distinguish them with some other label just in case.

Also note that a post will not show truncated if the reader is browsing your
monthly Archives and accessess that post directly by clicking on its title listed there. That's because upon clicking the post title a full individual post page opens. Posts will only show truncated on the front and following pages of your blog (accessed via buttons Newer posts/Home/Older posts) because those pages host several posts each and you do not open individual post pages to read them.

No comments: