我正在 Locomotive CMS 中构建一个自定义导航片段,我希望 content_type 条目与页面一起列在导航中。
具体来说(显然)我只希望在content_type设置了 content_type_template 时列出条目。
我的计划是在 content_type_template 页面上设置一个句柄(在此处引用但最终从文档中丢失),然后在遍历页面时运行以下逻辑:
{% assign myContentType = loopPage.handle %}
{% for item in contents.myContentType %}
<li>a href="{{ item._slug }}">{{ item.name }}</a></li>
{% endfor %}
但是我遇到了一个问题:似乎我不能以这种方式使用变量。我认为尝试用字符串值代替 content_type slug 插入变量存在某种问题。我不会认为这会是一个问题,但它不起作用。
我也试过:
{% for item in contents[myContentType] %}
并且可以肯定的是:
{% for item in contents[myContentType].items %}
没有喜悦。
如何使用 Liquid 变量在 Locomotive CMS 中动态定位 content_types?