0

I have the entity degree. I created a view to represent the data of the degree. The system name of my view is data-degree. I created a twig template with name 'views-view-data--degree.html.twig'. I'm trying to represent the fields 'presentation', 'main-goal' and 'competencies' in my view. I tried many ways to do it, but the data is not rendering. I try to print dump(rows) but nothing is seen. As far as I understand, views return rows.

How could I then render these fields?

2
  • Hi Óscar, welcome to Drupal Answers. First, check the name of your twig template because I think the first issue is the name of your template. When you're debugging twig issues, it can be helpful to enable twig debugging (though be careful to NOT enable it on production environments). After enabling twig debugging, you can view the page's source code and see which template is being used to render the content and it'll also list all of the available template suggestions. Commented Jun 11, 2024 at 11:54
  • I'll add that based on the information you provided, I think you probably want to copy the views-view-fields template (or get a copy from your base theme) and name your template something like views-view-fields--data--degree.html.twig following the naming convention views-view-fields--VIEW-ID--DISPLAY-ID.html.twig Commented Jun 11, 2024 at 12:16

1 Answer 1

0

I had two problems. I wanted to see what I got when accessing said url and I tried to use dump but nothing came out. This was because I have a boostrap5-based subtheme configured, and in the settings.local.php file I did not have the path to development.services.yml configured correctly.

On the other hand, after solving this, I was able to do dump(). With this I observed that a result row was returned. So to access the fields I did it through view.result[0]._entity.field_name.value.

Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.