I have a CT team_members
with the following fields.
field_team_member_image
field_team_member_name
field_member_designation
field_social_media_links(Multiple values with links to twitter, instagram, fb and linkedin)
I created a view block out of it and placed it in my desired region.
Now when I templated this,
in the block template(block--theme-name-views-block--team-members-block-block-1.html.twig
), I gave the outline with the title and label as follows:
<section id="team" class="team">
<div class="container" data-aos="fade-up">
<div class="section-title">
<h2>Team</h2>
<p> {{ label }} </p>
</div>
<div class="row">
{{ content }}
</div>
</div>
</section>
and for each repeating field(views-view-fields--team-members-block.html.twig
) template:
<div class="col-lg-3 col-md-6 d-flex align-items-stretch">
<div class="member" data-aos="fade-up" data-aos-delay="100">
<div class="member-img">
<img src="{{ fields.field_team_member_image.content }}" class="img-fluid" alt="">
<div class="social">
{% for item in fields.field_social_media_links %}
<a href="{{ item.url }}"><i class="bi bi- {{ item.title }}"></i></a>
{% endfor %}
</div>
</div>
<div class="member-info">
<h4>{{ fields.field_team_member_name.content }}</h4>
<span>{{ fields.field_member_designation.content }}</span>
</div>
</div>
</div>
But the image is not displaying at all (name and designation coming). I changed the image
to URL to image
in the view field formatter. Also, the social media links are not iterating and not displaying the links I need. Any help is appreciated.
UPDATE
Image worked with directly given the field and applying the image style from the view settings.
Now the problem is with displaying the links
When I did the kint on the links field (
{{ kint(fields.field_social_media_links.content) }}
) I got it as follows:
protected string -> string (427) " <!-- THEME DEBUG --> <!-- THEME HOOK: 'views_view_field' --> <!-- BEGIN OUT...
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->
<a href="https://www.twitter.com">twitter</a>, <a href="https://www.facebook.com">facebook</a>, <a href="https://www.instagram.com">instagram</a>, <a href="https://www.linkedin.com">linkedIn</a>
<!-- END OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->
Hope somebody got insight on this.
block template
and then theview fields template
. Image is saved in sites/default/files