0

How to print fields value in views-view.html.twig I have created a views-view.html.twig file for my view slider_3. The template name is 'views-view--slider_3.html.twig' The view formatting is done by this template, but I need a field is come at begging position of the view:

<div class="slider-3-main">{{ rows.required_field }} <div{{ attributes.addClass(classes) }}> {{ title_prefix }} {% if title %} {{ title }} {% endif %} {{ title_suffix }}

How can be the field will written to display at {{ rows.required_field }}

  • I have created a ECK (drupal.org/project/eck) field in content type field as "Entity reference". Now need to print this field in a view. How can achieve it? – user50292 Sep 22 '17 at 12:44
2

To get a field value of the first result row view.result[0] use the method EntityField::getValue of the view field:

{{ view.field.field_example.getvalue(view.result[0]) }} 
| improve this answer | |
  • Waw this is amazing, its working. Thanks a lot for this. Could you please explain by which manner you have got this solution using EntityField::getValue – user50292 Aug 3 '17 at 10:31
  • From the php code, see drupal.stackexchange.com/a/219537/47547 – 4k4 Aug 3 '17 at 11:15

Your Answer

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