3

How can I override the html.tpl.php template for only the "teaser" view mode of the "Article" content type?

I found this on the Drupal 7 Template (Theme Hook) Suggestions page on drupal.org page, but cannot see how to drill down to a specific view mode for a single content type.

html.tpl.php base template: html.tpl.php The following are some examples of how you may override the base template:

  1. html--internalviewpath.tpl.php
  2. List item

html--node--id.tpl.php

See html.tpl.php in the Drupal API documentation for more information.

Will I need to implement a page preprocess hook to accomplish this?

8

As I am sure you know, the teaser view is only/mostly used when a list of nodes are put together, eg, the promoted to front page listing, a View listing, etc.

So, let's say you have a View page listing the most recent Articles, and it's sitting at www.yourhost.com/recent/articles, you could override the html.tpl.php there by creating a html--recent-articles.tpl.php file in your theme and modifying it accordingly.

Views itself also allows the use of node templates when a node is presented in a listing; if that is what you are needing or requiring, the template files there are along the lines of node-view-VIEWNAME.tpl.php.

1

Though Jimajamma is right, unless you're doing something insanely abstract, I wouldn't recommend doing a template override to simply edit a "teaser".

If you need more control of your displays, use Display Suite, maybe even combined with DS Extras if you need more functionality.

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.