【发布时间】:2018-06-09 19:45:48
【问题描述】:
我在 lib/modules/apostrophe-custom-pages/index.js 中添加了一些自定义字段
具体来说,我为摘录添加了一个字段,为封面图片添加了图像单例,以及另一个允许用户为页面定义图标的单例。
这就是这些图像的定义方式:
{
name: 'icon',
label: 'Icon',
type: 'singleton',
widgetType: 'apostrophe-images',
options:{
limit: 1,
minSize: [200,200],
aspectRatio: [1,1],
},
controls:{
movable:false
},
image: true
},
{
name: 'coverimg',
label: 'Header Image',
type: 'singleton',
widgetType: 'apostrophe-images',
options:{
limit: 1,
minSize: [400,400],
aspectRatio: [1,1],
},
controls:{
movable:false
},
image: true
}
封面图片和我可以在页面上检索的图标使用:{% set coverimage = apos.images.first(data.page.coverimg) or null %},
但是,我无法访问data.home._children 下导航中的图标,如下所示:
{%- for tab in data.home._children -%}
{%- set iconImg = apos.images.all(tab.icon) %}
{{ apos.log(tab) }}
<li>
<a class="sidebar-main-link
{% if data.page and (apos.pages.isAncestorOf(tab, data.page) or tab._id == data.page._id) %}
active
{% endif %}
" href="{{ tab.slug }}">
<div class="icon" style="
backgroung-image: url('{{ apos.attachments.url(image.attachment, { size: 'full'}) }}') "></div>
{{ tab.title }}
</a>
</li>
{% endfor %}
这将返回标准 missing.svg 图像
【问题讨论】:
标签: customization apostrophe-cms