Php 旁白中的标题如何呼应?
我是bolt的新手,我正在尝试理解默认主题中的一些代码,我在我的_aside.twig模板中看到了下面的代码:Php 旁白中的标题如何呼应?,php,bolt-cms,Php,Bolt Cms,我是bolt的新手,我正在尝试理解默认主题中的一些代码,我在我的_aside.twig模板中看到了下面的代码: {% for ct in config.get('contenttypes') if not ct.viewless|default(false) %} {% setcontent records = ct.slug ~ "/latest/3" %} <h5>{{ __('contenttypes.generic.rece
{% for ct in config.get('contenttypes') if not ct.viewless|default(false) %}
{% setcontent records = ct.slug ~ "/latest/3" %}
<h5>{{ __('contenttypes.generic.recent', {'%contenttypes%': ct.name}) }}</h5>
<ul>
{% for record in records %}
<li><a href="{{ record.link }}">{{ record.title }}</a></li>
{% else %}
<li>{{ __('contenttypes.generic.no-recent', {'%contenttype%': ct.slug}) }}</li>
{% endfor %}
</ul>
<p><a href="{{ path('contentlisting', {'contenttypeslug': ct.slug}) }}">{{ __('contenttypes.generic.overview',{'%contenttypes%': ct.name}) }} »</a></p>
{% endfor %}
上面这行代码到底在做什么,我知道它在旁边添加了标题,如“最新文章”、“最新文章”,但它到底是如何工作的?如您所见:
这些消息具有名称空间,便于转换。您提到的代码只是将字符串%contenttypes%
替换为实际的内容类型名称,然后打印新消息
{{ __('contenttypes.generic.recent', {'%contenttypes%': ct.name}) }}