类 CmsContentListDirective

所有已实现的接口:
Directive, HttpDirective, freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel

@Component public class CmsContentListDirective extends AbstractTemplateDirective
contentList 内容列表查询指令

上下文变量

  • lang:语言

参数列表

  • categoryId:分类id,当parentId为空时有效
  • containChild:是否包含子分类,【true,false】
  • categoryIds:多个分类id,当categoryId为空时有效
  • modelId:多个模型id
  • parentId:父内容id
  • onlyUrl:外链,【true,false】
  • hasImages:拥有图片列表,【true,false】
  • hasFiles:拥有附件列表,【true,false】
  • hasProducts:拥有产品列表,【true,false】
  • hasCover:拥有封面图,【true,false】
  • userId:发布用户id
  • startPublishDate:起始发布日期,【2020-01-01 23:59:59】,【2020-01-01】
  • endPublishDate:终止发布日期,高级选项禁用时不能超过现在,【2020-01-01 23:59:59】,【2020-01-01】
  • advanced:开启高级选项, 默认为false
  • status:高级选项:内容状态,【0:操作,1:已发布,2:待审核,3:驳回】
  • disabled:高级选项:禁用状态,默认为false
  • emptyParent:高级选项:父内容id是否为空,【true,false】,当parentId为空时有效
  • title:高级选项:标题
  • absoluteURL:url处理为绝对路径 默认为true
  • absoluteId:id处理为引用内容的ID 默认为true
  • containsAttribute默认为false,http请求时为高级选项,为true时content.attribute为内容扩展数据map(字段编码,value)
  • orderField 排序字段,【score:评分,comments:评论数,clicks:点击数,collections收藏数,publishDate:发布日期,updateDate:更新日期,checkDate:审核日期】,默认置顶级别倒序、发布日期按orderType排序
  • orderType:排序类型,【asc:正序,desc:倒序】,默认为倒序
  • firstResult:开始位置,从1开始
  • pageIndex:页码,firstResult不存在时有效
  • pageSize:每页条数
  • maxResults:最大结果数

返回结果

使用示例

<#assign lang="cn"/> <@cms.contentList pageSize=10><#list page.list as a>${a.title}<#sep>,</#list></@cms.contentList>

  <script>
    fetch('${site.dynamicPath}api/directive/cms/contentList?pageSize=10',{"headers":{"lang":"cn"}}).then(res => res.json()).then(data=>{
      console.log(data.page.totalCount);
    });
    </script>