PHP建站技术分享-从入门到精通PHP建站技术分享-从入门到精通PHP建站技术分享-从入门到精通

QQ:420220301 微信/手机:150-3210-7690
当前位置:首页 > CMS教程 > ThinkCMF

文章列表调用

管理员 2024-12-15
ThinkCMF
150

文章列表主要是通过articles标签生成。使用此标签时一定要先引入门户应用标签库。

articles标签

此标签要加载门户应用标签库app\portal\taglib\Portal

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

标签属性:

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

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

<php>
	$category_ids=1;</php><portal:articles limit="5" order="post.published_time DESC"
                 categoryIds="$category_ids">
    <dl class="dl-horizontal">
        <dt>
            <a class="img-wraper"
               href="{:url('portal/Article/index',array('id'=>$vo.id,'cid'=>$vo.category_id))}">
                <if condition="empty($vo.more.thumbnail)">
                    <img src="__TMPL__/public/assets/images/default_tupian4.png"
                         class="img-responsive" alt="{$vo.post_title}"/>
                    <else/>
                    <img src="{:cmf_get_image_url($vo.more.thumbnail)}"
                         class="img-responsive" alt="{$vo.post_title}"/>
                </if>
            </a>
        </dt>
        <dd>
            <a href="{:url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$vo.category_id))}">{$vo.post_title}</a>
        </dd>
    </dl></portal:articles>

一个文章列表,分页

<div>
    <php>
        $where=function($query){
            $query->where('post.create_time','egt',0);
        };    </php>
    <portal:articles item="vo"  where="$where" order="post.create_time DESC" page="10"
                     relation="categories"
                     categoryIds="$category.id"
                     returnVarName="articles_data">
        <div class="list-boxes">
            <h2><a href="{:cmf_url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$category['id']))}">{$vo.post_title}</a>
            </h2>
            <p>{$vo.post_excerpt}</p>
            <div>
                <div class="pull-left">
                    <div class="list-actions">
                        <a href="javascript:;"><i class="fa fa-eye"></i><span>{$vo.post_hits}</span></a>
                        <a href="{:url('portal/Article/doLike',array('id'=>$vo['id']))}"
                           class="js-count-btn"><i class="fa fa-thumbs-up"></i><span class="count">{$vo.post_like}</span></a>
                        <a href="{:url('user/Favorite/add',array('id'=>$vo['id']))}"
                           class="js-favorite-btn" data-title="{$vo.post_title}"
                           data-url="{:cmf_url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$category['id']))}"
                        >
                            <i class="fa fa-star-o"></i>
                        </a>
                    </div>
                </div>
                <a class="btn btn-warning btn-sm pull-right"
                   href="{:cmf_url('portal/Article/index',array('id'=>$vo['id'],'cid'=>$category['id']))}">查看更多</a>
            </div>
        </div>
    </portal:articles></div><ul class="pagination">
    <page/></ul>



希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。

相关推荐

扫码关注

qrcode

QQ交谈

回顶部