I'm trying to load some of the information from the author into a node--article.html.twig. So I can provide some information like bio, social media,etc.
Similar to this...
I can easily get the author_name
and the author_picture
because these two are given by the template. I added extra field at admin/config/people/accounts/fields
in this case the only extra field is field_bio
I try to use the include to add this user field into.
node--article.html.twig
<h4>{{ author_name }}</h4>
<p>{% include('field--user--field-bio--user.html.twig') %}</p>
This what I have on the field template - field--user--field-bio--user.html.twig
<span{{ attributes }}>
{%- for item in items -%}
{{ item.content }}
{%- endfor -%}
</span>
<p>Hello</p>
The word "Hello" is been display on the node--article.html.twig; however, the item.content
which is my field information is not been load. =(
I also try to dig up into the user variables by using {{ kint() }}
to see if there is this information and I did not find it either.
I have seen some example with a module, which I have avoid them because this is for a contrib theme and I do not want to have any module dependency. I have done this many times with DS but I do not want to use any extra module.
So I have couple questions...
- Should I use include for this use case or not ?
- If I have too, what I'm doing wrong ? Why the
item.content
is not been load ? - If I should not use it in this use case, what should I do instead ?
- If I have too, what I'm doing wrong ? Why the