Building a navigation system for a news or blog based on years and months (like an archive as an example) requires that we know what years and months are available for:
- The top level – as in when we open the home page
- Expanded – whenever we are viewing a month or article page and need to expand accordingly
- Dynamically – when we need to build the navigation in one shot, perhaps as an accordion or similar.
Note – we are assuming the following structure:
Year/ +-Month +-Month/ Article A Article B +-Month Year/ Year/
Its possible to code around these by doing Axes calls on the current item and getting the parents and siblings but this doesn’t scale well. Especially if you need to start dropping into sibling months to hide and show depending if they’re empty or not. And we haven’t even talked about languages.
An alternative approach is to use your Lucene index and scan it for all your news items in the current language and group them by year and month and store counts for each. Then you can cache this for even more speed.
Continue reading