2

I have created a vocabulary and using a 2 level tree for organizing content into categories. Each category and sub-category will have it's own page, where a view block will list the teasers from the content types linked to the filtered term(s).

Now I can go and create a View block for each category, but that just doesn't seem to be proper. I'm new to Views and I have been reading a lot but I'm still not at ease with best practices on using Views.

Should I create just one single View and make a Display for each category or there's a better way to do this?

I'll be using Panels to lay out the category pages. Do I have to create 1 page for each category/subcategory and add the corresponding view to it? Is there's a better Panel's usage strategy, that permits to skip the use of multiple page panels ?

I'm using D7, Views 3.3, Panels 3.2

3

I don't know if you figured this out already, but I'll give a quick answer.

The magic you need: arguments / contextual filters. You want to have just one Views block that takes term IDs as arguments (in a contextual filter), so it will filter on the term present in the url. Instead of a regular views block, you can also use a Views content pane (for tighter integration with Panels).

As for Panels: you need one panel page to override the taxonomy system path. When you enable Page manager (part of CTools) some page override templates are provided, just activate the taxonomy one.

Add a variant (you can optionally add a selection rule if you want this override to only work on terms of one vocabulary) and add your Views block. Since this is a taxonomy system path, term IDs are already available as arguments for the view block (Panels is also excelent for manipulating which arguments the page will provide).

Page manager, Panels and Views are complex so it's a good idea to understand how it works. I recommend checking out NodeOne's Learn Page manager screencasts (especially Views content panes), and maybe also parts of the Views series (especially contextual filters).

  • Thank you for the detailed intro @arjan. Due to time issues with the project in question, I temporarily decided to do it the nasty way. Simply replicated a view block and panel page for each category, considering there aren't that many right now (8 overall). In the meanwhile I'm digging and learning the whole concepts behind content panes + Views contexts + panels variants. NodeOne tutos, Lullabot's Views DVD and this excellent tuto are helping me through this transition. – Tunox Jul 17 '12 at 14:08

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.