Contextual Views: stop using arg()!
(notes from a session at the DrupalCon 2010 Unconference)
very simple module: View default argument from Context allows Views arguments to be set by the Context module
- This allows, for example, a view displayed in a block to show information relevant to the current node (or its author, or its type, or its taxonomy terms) without having to use the arg() function. Reasons not to use the arg() function are explained on the project page.
- for example, using standard arg() requires arguments to always be in the same order, and they may not always be consistent
- works very well (according to presenter) and fast, because Views doesn't run the query unless the arguments are present. When contextual arguments are not present, block goes away. Can serve as a much simpler replacement for Panels!
- module doesn't yet do anything by itself -- a contrib or custom module would need to create the desired context. Will plan to add default context so it works out of the box, but custom possibilities are far more flexible.
- another possible application: SEO optimization, automatic meta keywords based on context.
- advertisers often want ads to appear only for certain types of content
- because contexts can be persistent for a given session, block could display "other items you might be interested in buying" for duration of a user's session, triggered by Ubercart's add-to-cart hook for example.
- admin's blog
Printer-friendly version- Add new comment
- 1007 reads




Recent comments
1 week 4 days ago
1 week 4 days ago
1 week 4 days ago
11 weeks 2 days ago
11 weeks 3 days ago
11 weeks 4 days ago
20 weeks 2 hours ago
20 weeks 13 hours ago
43 weeks 2 days ago
43 weeks 2 days ago