我刚刚浏览了listings.twig文件,并看到了以下代码行:
<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到底是什么吗?
发布于 2016-10-15 10:57:16
这是ContentType中的两个字段。它们是在app/config/contenttypes.yml中定义的。
粘贴的代码检查介绍字段是否可用或是否有内容,如果没有,它将尝试teaser字段。
https://stackoverflow.com/questions/40057687
复制相似问题