0

{{ node.field_test1.entity.label }} prints the label of a taxonomy field in a node.html.twig. Is there a possiblity to suppress that outside the frontpage via node.html.twig? Or enable that only for front_page? That means: in a view, that is searching for this term exactly, I have the same information double on screen in the view result.

"is_front"condition is not defined in node.html.twig. 'EDIT: What I meant is that:

{% if not page %}
      <h2{{ title_attributes.addClass('node__title') }}>
        <a href="{{ url }}" rel="bookmark">{{ node.field_kategorie.entity.label }}: {{ label }}</a>
      </h2>
    {% endif %}

This'll be printed all over. How to do: print this (in the URL above) only for front page, for example not not in a view (that just searched for this entity)?

2
  • You can add this variable in .theme in a preprocess hook.
    – Kevin
    Commented May 5, 2017 at 15:42
  • I found this only documented for D7. How to do that? Commented May 5, 2017 at 16:14

1 Answer 1

0

You can have as many differen view modes as you want, both the frontpage and the term pages by default are views, so they are easy to customize.

So create a new one under Admin > Structure > Display modes, then enable it for that node type and configure the fields as you want. Then change one of the views to use that view mode.

Another option would be logic in process, but then you need to add the right cache context.

Or you just hide that field with CSS.

1
  • I've tried to clarify my question above. Commented May 5, 2017 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.