codecamp

sp_sql_posts_paged_bykeyword

sp_sql_posts_paged_bykeyword

上一页下一页

X1.2新增

sp_sql_posts_paged_bykeyword($keyword,$tag,$pagesize=20,$pagetpl)

功能:

根据分类文章分类ID 获取该分类下所有文章(包含子分类中文章),已经分页,调用方式同sp_sql_posts_paged

参数:

$keyword:查询关键字;

$tag:查询标签,以字符串方式传入,例:"field:post_title,post_content;limit:0,8;order:post_date desc,listorder desc;where:id>0;"

    field:调用post指定字段,如(id,post_title...) 默认全部

    limit:数据条数,默认值为10,可以指定从第几条开始,如3,8(表示共调用8条,从第3条开始)

    order:排序方式,如:post_date desc

    where:查询条件,字符串形式,和sql语句一样

$pagesize:每页显示文章数

$pagetpl:分页模板,例:"{first}{prev}{liststart}{list}{listend}{next}{last}"

返回:

类型数组,符合条件的文章列表,文章总数及分页html

array(
    'posts=>'',//符合条件的文章列表
    'page'=>'',//分页html
    'count'=>'',//符合条件的文章总数
)

模板使用方法:

<div class="main-title">
    <php>
        $result=sp_sql_posts_paged_bykeyword($keyword,"",20);
    </php>
    <h3>'{$keyword}' 搜索结果 </h3>
    <p>{$result['count']}条结果</p>
</div>

<volist name="result['posts']" id="vo">
<php>
    $smeta=json_decode($vo['smeta'], true);
</php>

<div class="list-boxes">
    <h2><a href="{:leuu('article/index',array('id'=>$vo['tid']))}">{$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="{:U('article/do_like',array('id'=>$vo['object_id']))}" class="J_count_btn"><i class="fa fa-thumbs-up"></i><span class="count">{$vo.post_like}</span></a>
            <a href="{:U('user/favorite/do_favorite',array('id'=>$vo['object_id']))}" class="J_favorite_btn" data-title="{$vo.post_title}" data-url="{:U('portal/article/index',array('id'=>$vo['tid']))}" data-key="{:sp_get_favorite_key('posts',$vo['object_id'])}">
                <i class="fa fa-star-o"></i>
            </a>
            </div>
        </div>
        <a class="btn btn-warning pull-right" href="{:leuu('article/index',array('id'=>$vo['tid']))}">查看更多</a>
    </div>
</div>
</volist>

<div class="pagination">
    <ul>
        {$result['page']}
    </ul>
</div>

上一页下一页

sp_sql_post()
文章列表页制作
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

后台管理

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }