0

how can I assign my own html.tpl.php to a view (machine_name) via a preprocess-function (template.php) or a hook?

If my view is called "foo_view_machine_name_bla", which contains 50 views-pages with path, I would like to have a "html--foo_view_machine_name_bla.tpl.php".

I do not know songs how to do that.

Can someone help me please.

0

If I understand you correctly you are wanting to create a specific 'view' template file, your initial question is not clear. You also don't mention which Drupal version you are using. I will assume it's Drupal 7. Go to your specific view and click Advanced then select Theme. There is a list of file names used for the view. The highlighted templates are current. After is a list of suggested templates that can be used. It's quite safe to use the first example. Copy the highlighted file from core and save it to your themes/templates folder rename it to the suggested file name. Clear cache and revisit the same view > Advanced > themes section. Your new template file should now be highlighted. That's it! You are now control of the output. Edit the file as you wish.

  • NO! I need a HTML.TPL.PHP for a special view (with a lot of View-Pages with different path inside, NOT a views-view.tpl.php. For a content-type you can have html--YOUR_CONTENTTYPE.tpl.php - for a path html--YOUR--PATH.tpl.php - i need a html--VIEW_MACHINE_NAME.tpl.php this applies to all pages (with PATH) within the view (machine_name). In html.tpl.php you can define $script, $css & Co. – Steppke Oct 8 '18 at 21:22
  • If it's all pages, like @Viktor mentioned above try page.html.twig (D8) or page.tpl.php (D7) Clear cache and that is all you need ALL templates will use that file. If you want html.tpl.php do the same copy it from core and save it to your D7 theme template file. – Dupls Oct 8 '18 at 21:37
  • NO, MAN. In page.tpl.php YOU CAN NOT Define Variable $style, $css & Co. I need a special html.tpl.php NOT a page.tpl.php!!!!!!! html-markup, head, METATAGS, Scripts and so on will definde in html.tpl.php NOT a page.tpl.php!!!! You dont understand my Question? – Steppke Oct 8 '18 at 21:42

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.