Recent Changes - Search:

SimpleLog wiki

Installing SimpleLog

        MT(gs) users
        DreamHost users

Upgrading

Working with themes

How to

Troubleshooting

Development & resources

ArchiveHeadings

Add Proper Headings to Your by_tag and by_month Archive Pages

Even though SimpleLog 2.0.2 doesn't provide a way to easily determine what type of archive page we're viewing, Rails allows us to pull this data from URL parameters.

by_tag

Tags are relatively simple. We can pull in the name of the tag with <%= params[:tag] %>. You can drop this into your by_tag.rhtml view however you'd like. For example:

<h1>Archive for tag <%= params[:tag] %></h1>

by_month

Monthly tags present a more difficult problem. We can pull the month with <%= params[:month] %>, but then we're left with a number, rather than a name. In order to properly format it, we need to do a little conversion: <%= Time.parse("#{params[:month]}/01").strftime('%B') -%>. This will convert 02 to February.

The strftime() parameter may be exchanged for any found in ruby-docs. This functions exactly like the date and time preferences for SimpleLog.

Our final example might be expanded to look more like:

<h1>Archive for <%= Time.parse("#{params[:month]}/01").strftime('%B') -%>, <%= params[:year] %></h1>

Edit - History - Print - Recent Changes - Search
Page last modified on January 08, 2008, at 12:36 PM EST