0

I created a view for the front page and also a node--view--frontpage.html.twig to design this view. Is there any opportunity to catch the first node with a if statement to design it differently?

In this case I want to change the order of the first iteration in the node--view--frontpage.html.twig:

{% set createdDate = node.getCreatedTime | date('j.m.Y') %}
<article{{ attributes }}>
  {{ content.field_picture }}
  <div class="meta">
    {{ createdDate }}
    {% if content.typ | render | trim %}
      , {{ content.typ }}
    {% endif %}
  </div>
  <h2 class="news" {{ title_attributes }}>
    <a href="{{ url }}" rel="bookmark">{{ label }}</a>
  </h2>
  {{ content.body }}
</article>
1
  • You should elaborate your question further more. Please paste the relevant code that you've so far.
    – kenorb
    Commented Sep 23, 2016 at 13:22

1 Answer 1

1

The display suite module has a views integration that allows you to choose a different display mode for the first node in a view versus all the others. In this case you can easily create a separate tpl for that view mode and you're good to go. Its extremely powerful. Take a look at this post and look for "Alternating view modes" in the last screen shot.

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.