articles标签

标签名 作用 包含属性
articles 获取文章列表 field,where,limit,order,page,relation,pageVarName,categoryIds,item

标签属性:| 标签属性名 | 含义 || —- | —- || where | 查询条件变量, 支持数组和字符串,如$where || limit | 最多查出文章数,如果分页开启,此设置无效 || order | 文章排序方式 || page | 分页参数,如果设置分页参数会自动分页 || relation | 关联查询,支持categoriesuser,多个以英文逗号分隔 || pageVarName | 分页后生成的分页变量名,只有设置分页参数时才有效 || categoryIds | 分类 id,支持数组和字符串(英文逗号分开)|

一个最新文章列表,不分页

  1. <php>
  2. $category_ids=1;
  3. </php>
  4. <portal:articles limit="5" order="post.published_time DESC"
  5. categoryIds="$category_ids">
  6. <dl class="dl-horizontal">
  7. <dt>
  8. <a class="img-wraper"
  9. href="{:url('portal/Article/index',array('id'=>$vo.id,'cid'=>$vo.category_id))}">
  10. <if condition="empty($vo.more.thumbnail)">
  11. <img src="__TMPL__/public/assets/images/default_tupian4.png"
  12. class="img-responsive" alt="{$vo.post_title}"/>
  13. <else/>
  14. <img src="__TMPL__/public/assets/images/default_tupian4.png"
  15. class="img-responsive" alt="{$vo.post_title}"/>
  16. </if>
  17. </a>
  18. </dt>
  19. <dd>
  20. <a href="{:url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$vo.category_id))}">{$vo.post_title}</a>
  21. </dd>
  22. </dl>
  23. </portal:articles>

一个文章列表,分页

  1. <div>
  2. <php>
  3. $where=[
  4. 'post.create_time'=>['egt',0]
  5. ];
  6. </php>
  7. <portal:articles item="vo" where="$where" order="post.create_time DESC" page="10"
  8. relation="categories"
  9. categoryIds="$category.id"
  10. returnVarName="articles_data">
  11. <div class="list-boxes">
  12. <h2><a href="{:cmf_url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$category['id']))}">{$vo.post_title}</a>
  13. </h2>
  14. <p>{$vo.post_excerpt}</p>
  15. <div>
  16. <div class="pull-left">
  17. <div class="list-actions">
  18. <a href="javascript:;"><i class="fa fa-eye"></i><span>{$vo.post_hits}</span></a>
  19. <a href="{:url('portal/Article/doLike',array('id'=>$vo['id']))}"
  20. class="js-count-btn"><i class="fa fa-thumbs-up"></i><span class="count">{$vo.post_like}</span></a>
  21. <a href="{:url('user/Favorite/add',array('id'=>$vo['id']))}"
  22. class="js-favorite-btn" data-title="{$vo.post_title}"
  23. data-url="{:cmf_url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$category['id']))}"
  24. >
  25. <i class="fa fa-star-o"></i>
  26. </a>
  27. </div>
  28. </div>
  29. <a class="btn btn-warning btn-sm pull-right"
  30. href="{:cmf_url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$category['id']))}">查看更多</a>
  31. </div>
  32. </div>
  33. </portal:articles>
  34. </div>
  35. <ul class="pagination">
  36. <page/>
  37. </ul>

原文: https://www.thinkcmf.com/docs/cmf/文章列表标签.html