1

I created a content type "Troubleshooting Options". I want to render the title of this content in a different way. To do this I overrode default field--node--title.html.twig with field--node--title--troubleshooting-options.html.twig (as recommended by twig debug).

I am unable to render the title in this new template. Tried {{ content.title }}, {{ node.title }}, {{ node.title.value }} but none worked. Although drupal caching is disabled I rebuilt cache every time.

Twig file name suggestions:

<!-- FILE NAME SUGGESTIONS:
   * field--node--title--troubleshooting-options.html.twig
   x field--node--title.html.twig
   * field--node--troubleshooting-options.html.twig
   * field--title.html.twig
   * field--string.html.twig
   * field.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/field/field--node--title.html.twig' -->

I am very new to Drupal.

3
  • You could instead create node--[troubleshooting-options].html.twig and then use the code provided in this answer
    – No Sssweat
    Nov 21, 2016 at 15:22
  • If I was to make a guess for your current template file, try {{ items.title.content }}
    – No Sssweat
    Nov 21, 2016 at 15:27
  • else try {%- for item in items -%} {{ item.title.content }} {%- endfor -%}
    – No Sssweat
    Nov 21, 2016 at 15:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.