功能说明
postparent 用于实现文档的父子关系,可以通过 postparent 字段获取父级文档的信息。
数据结构
在 archives 表中:
- postparent: 父级文档ID
- 当 postparent = 0 时表示顶级文档
- 当 post_parent > 0 时表示该文档有父级文档
标签使用
``
html
{cms:archives name="postparent" /}
{cms:archives name="post
parent|getUrl" /}
{cms:archives name="postparent|getTitle" /}
{cms:arclist id="item" postparent="ARCHIVES.id"}
{$item.title}
{/cms:arclist}
``使用示例
``
html
{if $ARCHIVES.postparent}
{/if}
{cms:arclist id="child" post
parent="ARCHIVES.id" orderby="weigh" orderway="asc"}
{/cms:arclist}
{cms:arclist id="level1" postparent="0"}
{$level1.title}
{cms:arclist id="level2" postparent="level1.id"}
{$level2.title}
{/cms:arclist}
{/cms:arclist}
``注意事项
1. post_parent 值必须是已存在的文档ID
2. 避免出现循环引用(A的父级是B,B的父级是A)
3. 建议控制层级深度,一般不超过3层
4. 修改父级时注意更新相关的导航和面包屑