ymakux
ymakux

Reputation: 3485

Rewrite default Drupal view programmatically

Say we have a defaul view (i.e hardcoded), provided by Views module , for example "taxonomy/term/%"

Now, I'd like to make some modification to that view programmatically, through an installation profile

Normally I use Features module for such work, but Features does not support default views.

Please advise how to do that.

Thanks!

Upvotes: 0

Views: 799

Answers (3)

user3563097
user3563097

Reputation: 179

Yes, use hook_views_default_views_alter()

Here's a good example: enter link description here

Upvotes: 0

Pierre Buyle
Pierre Buyle

Reputation: 4873

Use hook_views_default_views_alter

function MODULE_views_default_views_alter(&$views) {
  if (isset($views['taxonomy_term'])) {
    $views['taxonomy_term']->set_display('default');
    $views['taxonomy_term']->display_handler->set_option('title', 'Categories');
  }
}

Upvotes: 1

Collin White
Collin White

Reputation: 680

You should use the Views theme information. There is a link you can use to find out what you should name your views (Its called "Theme Information") copy the name of the particular part of the view you would like to hardcode and paste it as a new file in your template's directory. You can use a folder (I usually name it views) to separate these files from others in the template. You'll need to refresh your cache to see the changes once you've created the new template file(s).

Upvotes: 1

Related Questions