我只是通过使用bolt HERE 阅读内容,这让我对setcontent
的工作原理有了一个了解。现在我在默认的bolt主题中的_aside.twig模板中遇到了以下代码:
<div class="panel">
{# The next section attempts to fill the panel in the sidebar with the contents of the
'about-us'-block, if it exists. First, attempt to fetch the block with slug 'about-us' #}
{% setcontent block = "block/about-us" %}
{# check if we have a title. If so, we know we have content to display. Otherwise, we will
output a default text, telling the user to create the 'blocks' in the backend. #}
{% if block.title is defined %}
<h5>{{ block.title }}</h5>
{{ block.content }}
{% if link(block.contentlink) or block.editlink() %}
<p>
{{ link(block.contentlink, __('general.phrase.read-more')) }} /
<a href="{{ block.editlink() }}">{{ __('general.phrase.edit') }}</a>
</p>
{% endif %}
{% else %}
<h5>{{ __('general.phrase.missing-about-page') }}</h5>
<p>{{ __('general.phrase.missing-about-page-block') }}</p>
{% endif %}
</div>
我的问题是关于以下代码行:
{% setcontent block = "block/about-us" %}
"block/about-us"
来自哪里?
答案 0 :(得分:1)
它指的是about-us
ContentType上带有slu blocks
的记录。它被设置为资源ContentType。您可以在此处阅读有关资源ContentTypes的更多信息:
https://docs.bolt.cm/3.1/howto/resource-contenttype