Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.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
Php 旁白中的标题如何呼应?_Php_Bolt Cms - Fatal编程技术网

Php 旁白中的标题如何呼应?

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

我是bolt的新手,我正在尝试理解默认主题中的一些代码,我在我的_aside.twig模板中看到了下面的代码:

{% 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}) }} &raquo;</a></p>


        {% endfor %}
上面这行代码到底在做什么,我知道它在旁边添加了标题,如“最新文章”、“最新文章”,但它到底是如何工作的?

如您所见:

这些消息具有名称空间,便于转换。您提到的代码只是将字符串
%contenttypes%
替换为实际的内容类型名称,然后打印新消息

{{ __('contenttypes.generic.recent', {'%contenttypes%': ct.name}) }}