By Ben Nitkin on
Views is an amazing module.
By default, the Drupal homepage shows a "Teaser" of each node (piece of content) that's been promoted to the front page. If there are more than 10 posts, it'll do you the favor of displaying a pager at the bottom. That's all it does, though. There's no filtering, only rudamentary ordering, and general lack of customization.
When the site came online, I used the Path module to give content a snazzy URL (in lieu of the Drupal default "nitkin.net/node/17"). All of the articles (the things in the frontpage use the URL format "nitkin.net/year/month/title"). I wanted the home page to filter using the same yyyy/mm scheme to allow granular browsing.
nitkin.net/2012 shows all posts from 2012
nitkin.net/2012/6 shows all posts from June 2012nitkin.net/2012/6/views displays this post
That's where Views comes in.
Views has a feature called "Contextual Filters" (in D6, it went by "Arguments"). These filters filter results based on the URL. A % sign in a URL is replaced with the arguments, in order. A view with the path "/frontpage/%" will capture visits to "/frontpage/2012", or "/frontpage/2012/6", and parse accordingly. This site's new frontpage accepts the arguments hinted at: first year, then month. Forward slashes seperate arguments.
The only problem is that Views insisted on a trailing slash to access the front page. Global Redirect, which assigns each piece of content a unique URL, stripped that slash. To work around the problem, I added another display in Views. One of the displays handles filtering; the other handles the unfiltered homepage:
nitkin.net/frontpage/2012 is handled by the filtering display
nitkin.net/frontpage is handled seperately
In half an hour, I created a new frontpage with exactly the features I wanted. Views is impressive.