输出项目.在重复部分中的类别



我不知道如何从collection.items输出类别。我可以循环浏览集合。类别 {.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

使用示波器参考,写为{@},允许您引用密钥 您被范围界定。这就像javascript中的 (this)

最新更新