标签手册

栏目标签

更新于 2026-11-13 阅读 4 # 栏目标签 栏目标签用于输出栏目树、子栏目与同级栏目。 ## 栏目列表 `channel` 读取栏目列表,支持一级、子… Markdown

栏目标签

栏目标签用于输出栏目树、子栏目与同级栏目。

栏目列表 channel

读取栏目列表,支持一级、子级、同级与当前顶级栏目;标签本身直接循环,默认变量为 $item。

调用格式

{pycms:channel type="top"}...{/pycms:channel}

参数

参数说明默认取值 / 备注
type范围toptop 顶级 / son 子栏目 / peer 同级 / selftop 顶级(同 top)
name栏目 ID当前栏目type 为 son、peer 时指定父栏目或参照栏目
num输出条数20最大 50
model模型 ID空只输出指定内容模型的栏目
istotal统计内容数0填 1 时每项带 total
currentstyle选中样式active当前栏目命中的 class 名
id循环变量名item改为 nav 后使用 $nav.title

可用字段

  • $item.id
  • $item.title / name
  • $item.href / url
  • $item.has_child
  • $item.total
  • $item.currentstyle
  • $item.initial

完整示例

{pycms:channel type="son" name="$category.id" istotal="1" id="sub"}
    <a class="{$sub.currentstyle}" href="{$sub.href}">{$sub.title}({$sub.total})</a>
{/pycms:channel}
栏目 URL 由 /list/{slug} 生成;顶部菜单请优先使用 nav 标签。