如何在 CraftCMS 中的嵌套条目的 URI 之前包含不同的段

问题描述 投票:0回答:0

我正在使用 CraftCMS 制作网络漫画。我有一个带有两个类型句柄(系列,单个)的结构部分,我想在嵌套条目的 URI 之前包含一个不同的部分,如下所示:

Title 1:example.com/series/title-1(父条目,条目类型:series)。此条目显示描述、附加信息和所有子条目(章节)。

  • 第 1 章:example.com/read/title-1/chapter-1(上述条目的子项,条目类型:single
  • 第 2 章:example.com/read/title-1/chapter-2(上述条目的子项,条目类型:single
  • 第 3 章:example.com/read/title-1/chapter-3(上述条目的子项,条目类型:single

Title 2:example.com/read/title-2(无章短篇小说,条目类型:single

Title 3:example.com/read/title-3(无章短篇小说,条目类型:single

路径seriesread是根据条目类型和级别。我试过这段代码来格式化 Structure 部分中的 slug,但它不起作用。

{% if level == 1 and type.handle == 'series' %}series
{% elseif level == 1 and type.handle == 'single' %}read
{% else %}read
{% endif %}{parent.uri}/{slug}-{id}

使用上述条目 URI 格式,顶级条目的 URI 将是 series/title-1read/title-2read/title-3,嵌套条目具有 series/title- 1/第 1 章

嵌套条目的 URI 之前的段仍然是 /series/。让我知道如何纠正它。谢谢你的回答!

twig craftcms
© www.soinside.com 2019 - 2024. All rights reserved.