标签手册
栏目标签
栏目标签
栏目标签用于输出栏目树、子栏目与同级栏目。
栏目列表 channel
读取栏目列表,支持一级、子级、同级与当前顶级栏目;标签本身直接循环,默认变量为 $item。
调用格式
{pycms:channel type="top"}...{/pycms:channel}
参数
| 参数 | 说明 | 默认 | 取值 / 备注 |
|---|---|---|---|
type | 范围 | top | top 顶级 / 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 标签。