注:对于文章而言,channel_id为栏目编号,id为内容编号,用法类似。
栏目channel_id可以是一个固定值:3
{content@list cid="3"}
id可以是多个值固定值,相当于in(ids)
{channel@list id="2,4,6"}或{channel@list id="in(2,4,6)"}
id一个表达式
gt|eq|lt|egt|elt|neq|<|>|=|!=|in|notin|not in|like|not like|notlike|between|not between|notbetween
避免使用尖括号> <,因为有些编辑器会识别为html标签起止符号,代码解析错误报警告
{content@list cid="gt 5"}
注意:id只能一个条件,不支持and多条件写法,如 id="gt 3 and lt 10"是错误的
多个条件时,可以使用where
{content@list where="id gt 30 and id elt 40"}
限制输出数量,如num="3"
指定排序方式,如order="sort asc"
指定循环变量,如item="hello",默认为@前面的名称,如content。在某些情况下多列表嵌套时指定不同名称可 能有用。
指定查询字段,如fields="id,title,description",默认是所有字段。谨慎使用,有的字段在表间关联时需要。
使用缓存,如cache="index_news_7,3600"
{list cid="7" num="3" order="sort asc" item="hello" cache="index_news_7,3600"}
分页列表,使用pagesize参数后,列表会分页显示,如pagesize="5",每页显示5条记录
注意区分num和pagesize,使用num不产生分页链接
控制分页导航位置,正常情况下,分页连接跟随列表后面,可以使用links="no"列表下面的分页链接暂不显示
然后可以在其他地方输出分页链接
{content@list id="between 70 and 90" pagesize="5" links="no"}
列表赋值,可以使用assign="mylist",将列表内容赋值给变量mylist,可以在其他地方输出
{content@list where="title like '%经济%'" num="3" assign="mylist"}
读取id为100的文章内容
{content@get id="100"}