Drupal Technical
[Drupal Views] How to change Views display programmatically according to taxonomy tid
You could encounter a scenario in Drupal Views where you wish you could programmatically change the display for certain taxonomy ids, so that Views could show a teaser display for certain taxonomy ids and a field display for another set of taxonomy ids. Read on to find out how to change Views display programmatically according to taxonomy id so that you can implement it in your Drupal site.
Here is how to do it.
- Create a View page display that will act as the root display.
- Create a number of other display pages that will act as the sub display.
- Create a custom module unless you have already have a custom module.
- Implement a hook_views_pre_view hook using in your module.
- Within this hook call $view->set_display('your display') where your display should be the machine name of your display.
Hope that helps.
The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We can provide a wide range of Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.
Reference: http://drupal.org/node/415358