在重复部分内输出 items.categories
Output items.categories inside a Repeated Section
我不知道如何从 collection.items
输出类别。我可以遍历 collection.categories {.repeated section categories}{name}{.end}
,但是当我尝试在 collection.items.categories
上做更深层次的相同操作时,使用相同的语法输出每个单独项目的类别。没有输出。
{.repeated section items}
{.repeated section categories}{name}{.alternates with} / {.end}
{.end}
但是使用 json 格式化程序 categories|json-pretty
而不是 {name}
可以满足我的需要,并为每个项目吐出类别。我好像丢了钥匙。
代码示例:
<!--WORKS-->
<squarespace:category collection="team">
{.if categories}
<div class="button-group filter-button-group">
<button data-filter="*">All</button>
{.repeated section categories}<button data-filter=".{name}">{name}</button>{.end}
</div>
{.end}
</squarespace:category>
<!--DOES NOT WORK-->
<section class="grid">
<squarespace:query collection="team" limit="100">
{.repeated section items}
<div class="grid-item">
<img {customContent.teamImage|image-meta}/>
<h3>{customContent.teamName}</h3>
{.repeated section categories}{name}{.alternates with} / {.end}
</div>
{.end}
</squarespace:query>
</section>
有人能帮忙吗?谢谢。
当在 {.repeated section categories}
内时,您应该使用 {@}
来引用您确定范围的键。例如:
{.repeated section categories}{@}{.alternates with} / {.end}
参考:https://developers.squarespace.com/templating-basics#ReferencingtheScope
Using scope reference, written as {@}, allows you to reference the key
you're scoped into. This is like (this)
in JavaScript.
我不知道如何从 collection.items
输出类别。我可以遍历 collection.categories {.repeated section categories}{name}{.end}
,但是当我尝试在 collection.items.categories
上做更深层次的相同操作时,使用相同的语法输出每个单独项目的类别。没有输出。
{.repeated section items}
{.repeated section categories}{name}{.alternates with} / {.end}
{.end}
但是使用 json 格式化程序 categories|json-pretty
而不是 {name}
可以满足我的需要,并为每个项目吐出类别。我好像丢了钥匙。
代码示例:
<!--WORKS-->
<squarespace:category collection="team">
{.if categories}
<div class="button-group filter-button-group">
<button data-filter="*">All</button>
{.repeated section categories}<button data-filter=".{name}">{name}</button>{.end}
</div>
{.end}
</squarespace:category>
<!--DOES NOT WORK-->
<section class="grid">
<squarespace:query collection="team" limit="100">
{.repeated section items}
<div class="grid-item">
<img {customContent.teamImage|image-meta}/>
<h3>{customContent.teamName}</h3>
{.repeated section categories}{name}{.alternates with} / {.end}
</div>
{.end}
</squarespace:query>
</section>
有人能帮忙吗?谢谢。
当在 {.repeated section categories}
内时,您应该使用 {@}
来引用您确定范围的键。例如:
{.repeated section categories}{@}{.alternates with} / {.end}
参考:https://developers.squarespace.com/templating-basics#ReferencingtheScope
Using scope reference, written as {@}, allows you to reference the key you're scoped into. This is like
(this)
in JavaScript.