2

Drupal 7 you can style down to the fields on the page will we have this type of control with twig? I have reviewed a lot of documents about twig and didn't see anything that lets you have that same inheritance as the Drupal 7 template engine. If this is not built in to twig, is Drupal 8 going to be building it in?

7

I think you might be confusing inheritance with granularity. Twig actually does have the concept of template inheritance (see extends), while Drupal 7's theme engine doesn't.

The short answer is yes, you can expect the same from Drupal 8 as you did from Drupal 7. Specifically for fields, the example in the docs for field.html.twig will give you some insight:

For example, for a field named 'body' displayed on the 'article' content type, any of the following templates will override this default implementation. The first of these templates that exists is used:

field--node--field-foo--article.html.twig

field--node--field-foo.html.twig

field--node--article.html.twig

field--field-foo.html.twig

field--text-with-summary.html.twig

field.html.twig

These can be altered/added to using hook_theme_suggestions_alter(), or the more specific hook_theme_suggestions_HOOK_alter().

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.