0

I need to build a "blog archives" block with Views 3. I've seen (and am currently using) the solution at Archive block for nodes using Views, but this method doesn't allow specific enough paths.

Following the linked method, the summary output relies on the selected context filter. For example, if you use Content: Created Year+Month, your links turn out like base_path/YYYYMM - no separation between month and year. Likewise, if you use the Content: Created Year or Content: Created Date contextual filters you get a string output... not that great for organization.

Is it possible to generate a link path like base_path/YYYY/MM instead of a mixed string? I have attempted to create this solution using aggregation, count and grouped Views fields with no luck.

2

You'd have to create 2 views, one which takes Year argument with path base_path/yyyy and another that takes 2 arguments with path base_path/yyyy/mm

And you have to create a custom module which defines a hook_block_info and hook_block_view. This block will basically read your node table for blog type posts, and build links to the 2 views you created above, structured in Year > Month hierarchy. I'm not sure if there's an easier way to achieve this.

  • Nice, totally didn't think of doing it this way. It might work like that with an embedded view too, and passing the second argument... thanks man – emc Apr 27 '12 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.