开发者

Rewrite default Drupal view programmatically

开发者 https://www.devze.com 2023-02-02 09:05 出处:网络
Say we have a defaul view (i.e hardcoded), provided by Views module , for e开发者_运维知识库xample \"taxonomy/term/%\"

Say we have a defaul view (i.e hardcoded), provided by Views module , for e开发者_运维知识库xample "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!


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');
  }
}


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).


Yes, use hook_views_default_views_alter()

Here's a good example: enter link description here

0

精彩评论

暂无评论...
验证码 换一张
取 消