螺栓中的“record.introduction”和“record.teaser”是什么?
问题描述:
我正要通过listings.twig文件和跨越以下几行代码就来了:螺栓中的“record.introduction”和“record.teaser”是什么?
<h2><a href="{{ record.link }}">{{ record.title }}</a></h2>
{% if record.introduction %}
{{ record.introduction }}
{% elseif record.teaser %}
{{ record.teaser }}
{% else %}
<p>{{ record.excerpt(300, false, search|default('')) }}</p>
{% endif %}
现在究竟是什么record.introduction
和record.teaser
?我了解最后的else
部分,但我不太了解if
和elseif
部分。有人可以解释什么record.introduction
和record.teaser
真的是什么?
答
这是ContentType中的两个字段。它们在app/config/contenttypes.yml
中定义。
您的粘贴代码会检查引言字段是否可用或是否有内容,如果不是,则会尝试引导字段。