列表标签

首页调用模型列表

功能:通常用于网站首页调用模型内容列表信息

语法:



{eycms:rs top="10" table="ey_content" where="islock=1 and classid in([eycms.get_sonid(1)])" order="ordnum desc,createdate desc,id desc"}

{/eycms:rs}
    

参数:

属性 说明
top 返回记录条数,为0时显示全部
field 可选参数,查询字段,多个以英文逗号隔开,为空时系统自动识别所调用字段
table 必填参数,查询的数据表名称,通常为:ey_content、view_content
where 可选参数,查询条件,islock=1 and classid in([eycms.get_sonid(1)]) 表示:已发布 且 栏目ID为1及其子类中的所有内容
order 可选参数,排序条件
auto 可选参数,默认为auto="i",每个循环获得一个自增变量,从1开始递增

取值:

取值 说明
{$rs[link]} 内容链接
{$rs[title]} 内容标题
{$rs[ispic]} 是否含有缩略图
{$rs[pic]} 缩略图地址
{$rs[createdate]} 内容发布时间
{$rs[intro]} 内容概要
{$rs[hits]} 内容访问次数
{$rs[author]} 内容发布作者

实例:


                                                    
    <!-- 常规用法 -->
    {eycms:rs top="8" table="ey_content" where="islock=1 and classid in([eycms.get_sonid(1)])" order="ordnum desc,createdate desc,id desc"}
        <li>
            <a href="{$rs[link]}">{$rs[title]}</a>
        </li>
    {/eycms:rs}

    <!-- 调用指定模型的内容列表 -->
    {eycms:rs top="8" table="view_content" where="islock=1 and modeid=1" order="ordnum desc,createdate desc,id desc"}
        <dl>
            <dt>
                <a href="{$rs[link]}">{$rs[title]}</a>
            </dt>
        </dl>
    {/eycms:rs}

    <!-- 调用含有指定模型字段的内容列表 -->
    {eycms:rs top="8" table="view_model_down" where="islock=1 and classid in([eycms.get_sonid(1)]" order="ordnum desc,createdate desc,id desc"}
        <dl>
            <dt>
                <a href="{$rs[link]}">{$rs[title]}</a>
                <span><a href="{$rs[down_url]}">下载地址</a></span>
            </dt>
        </dl>
    {/eycms:rs}

常用where条件语句,多个条件以" and "连接:

语句 说明
islock=1 必选条件,表示已发布的内容
classid in([eycms.get_sonid(1)]) 最常用的条件,表示从ID为1的栏目及其子栏目中调取内容
ispic=1 含有缩略图的内容
isnice=1 设为推荐的内容
ontop=1 设为置顶的内容
modeid=1 从指定模型中获取内容,需配合table="view_content"

常用order条件语句,多个条件以","连接:

语句 说明
ordnum desc 按排序值降序排序
createdate desc 按发布时间降序排序
id desc 按ID降序排序
ontop desc 放在order条件最前面,表示置顶内容优先显示

内容列表页调用模型列表

功能:通常用于内容列表页调用模型内容列表信息

语法:



{eycms:rs table="view_attr_news" where="classid in([sonid]) and islock=1 [sql_where]" order="[sql_order]" pagesize="{var pagenum}"}

{/eycms:rs}
    

参数:

属性 说明
table 必填参数,查询的数据表名称,常用:view_content、view_model_news、view_attr_news等,
具体请看数据库字典--视图映射表
where 查询条件,classid in([sonid]) and islock=1 [sql_where] 表示:已发布 且 当前栏目及其子类中的所有内容,
sql_where为启用筛选时传递的变量
order 排序条件
pagesize 分页数量,{var pagenum}表示当前栏目设置的分页数量

实例:


                                                    
    <!-- 常规用法 -->
    {eycms:rs table="view_content" where="classid in([sonid]) and islock=1" order="[sql_order]" pagesize="{var pagenum}"}

    {/eycms:rs}

    <!-- 需要在列表中调用模型特定字段 -->
    {eycms:rs table="view_model_photo" where="classid in([sonid]) and islock=1" order="[sql_order]" pagesize="{var pagenum}"}

    {/eycms:rs}

    <!-- 需要在列表页实现按属性筛选功能 -->
    {eycms:rs table="view_attr_photo" where="classid in([sonid]) and islock=1 [sql_where]" order="[sql_order]" pagesize="{var pagenum}"}

    {/eycms:rs}

注意事项:

  1. 不同模型调用的视图名称不同:view_model_模型特殊符、view_attr_模型特殊符,具体请至 数据库字典--视图映射表 查看
  2. 模型特定字段,请至 后台--栏目--模型管理--字段管理--标记为“系统字段”的