我正在努力在 Apsotrophe CMS 上展示一些内容。
我正在使用apostrophe-pieces
创建描述字段:
{
name: 'description',
label: 'Description',
type: 'singleton',
widgetType: 'apostrophe-rich-text',
options: {
toolbar: [ 'Bold', 'Italic', 'Link', 'Unlink' ]
}
}
我希望它显示在自定义页面的 index.html 视图中。
但是,使用{{ apos.singleton(data.piece, 'description', 'apostrophe-rich-text') }}
会引发错误并且无法呈现页面。它只适用于show.html
在/lib/modules/basics-pages/views/index.html
,我的代码是:
{% extends "apostrophe-pages:outerLayoutBase.html" %}
{% block content %}
<div class="basics-grid">
{% for piece in data.pieces %}
<article>
<h4>{{ piece.title }}</h4>
{% set image = apos.images.first(piece.icon) %}
{% if image %}
<img src="{{ apos.attachments.url(image, { size: 'one-sixth' }) }}" />
{% endif %}
<div class="desc">
{{ apos.singleton(data.piece, 'description', 'apostrophe-rich-text') }}
</div>
</article>
{% endfor %}
</div>
{% endblock %}
有人可以帮助我使用正确的代码来显示单例小部件的内容吗?