Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drupal 8细枝实体引用子字段模板化_Drupal_Twig_Drupal 8_Templating - Fatal编程技术网

Drupal 8细枝实体引用子字段模板化

Drupal 8细枝实体引用子字段模板化,drupal,twig,drupal-8,templating,Drupal,Twig,Drupal 8,Templating,我试图显示多值实体引用的子字段 尝试: {% for item in node.field_related_items %} {{ item.content['#node'].field_author.value }} {% endfor %} 此外: 如果我这样做: {% for item in node.field_related_items %} {% set img1 = item.entity.field_fea

我试图显示多值实体引用的子字段

尝试:

    {% for item in node.field_related_items %}
            {{ item.content['#node'].field_author.value }}
    {% endfor %}
此外:

如果我这样做:

    {% for item in node.field_related_items %}
            {% set img1 = item.entity.field_featured_image %}
            {{ img1 }}
            {% set label1 = item.entity.label %}
            {{ label1 }}
    {% endfor %}
标签有效,但图像无效

同样的道理:

item.entity.field_featured_image.value
没有成功

仍然不确定如何显示实体引用的子字段


请帮忙

图像、分类、链接和普通字段模板的答案:

    {% for item in node.field_related_items %}
        <div class="col-sm-12 col-md-4">
            <div class="img-wrap">{{ file_url(item.entity.field_featured_image.entity.uri.value) }} </div>

            {% set cat1 = item.entity.field_blog_category.entity.label %}
            <div class="cat-wrap">{{ cat1 }}</div>

            {% set label1 = item.entity.label %}
            <div class="title-wrap">{{ label1 }}</div>

            {% set aut1 = item.entity.field_author.value %}
            <div class="author-wrap">By <span>{{ aut1 }}</span> | 

            {% set date1 = item.entity.field_publish_date.value %}
            {{ date1 }}</div>

            <a href="{{ path('entity.node.canonical', {'node': item.entity.id}) }}">Link</a>

        </div>
    {% endfor %}
    {% for item in node.field_related_items %}
        <div class="col-sm-12 col-md-4">
            <div class="img-wrap">{{ file_url(item.entity.field_featured_image.entity.uri.value) }} </div>

            {% set cat1 = item.entity.field_blog_category.entity.label %}
            <div class="cat-wrap">{{ cat1 }}</div>

            {% set label1 = item.entity.label %}
            <div class="title-wrap">{{ label1 }}</div>

            {% set aut1 = item.entity.field_author.value %}
            <div class="author-wrap">By <span>{{ aut1 }}</span> | 

            {% set date1 = item.entity.field_publish_date.value %}
            {{ date1 }}</div>

            <a href="{{ path('entity.node.canonical', {'node': item.entity.id}) }}">Link</a>

        </div>
    {% endfor %}