名称: articles_data

功能: 文章数据列表

示例: 

# 输出当前分类文章列表,若URL中不存在分类信息这读取前十篇
{loop $articles_data $k $article} <h2>{$article['title']}</h2> {/loop}

# 读取指定数量的文章列表
{php}$articles = EsiteApp::app()->articles_data(5);{/php}

# 自定义排序方式读取文章列表
{php}$articles = EsiteApp::app()->articles_data(5,'edit_time|sort|id|...');{/php}

# 按分类编号读取文章
{php}$articles = EsiteApp::app()->artielesByCatId('分类ID','排序方式[a.id desc]','文章数量');{/php}

 

调用示例:

{if($articles_data)}
{loop $articles_data $k $article}
<article data-category={json_encode($article['category_info'])}>
	<h3>
		<a href="{$article['category_info']['category_url']}">{$article['category_info']['cat_name']}</a>
		 
		<a href="{$article['article_url']}" class="permalink" title="{$article['title']}" >{$article['title']}</a>
	</h3>
	<div class="post-content post-list">
		{$article['content_description']}
		<span class="post-date"><?php echo date('Y-m-d', ($article['edit_time']));?></span>
	</div>
</article>
{/loop}
<div class="row margin-top-20">
	{php}$_pager_data = EsiteApp::app()->pager_data(['tag_start'=>'<ul class="pagination pull-right">', 'page_fix'=>5]);{/php}
	<div class="span4">{$_pager_data['summary_code']}</div>
	<div class="span5">{$_pager_data['code']}</div>
</div>
{/if}
 

数据格式打印:

Array
(
    [0] => Array
        (
            [id] => 8
            [cat_id] => 3
            [filename] => 程序执行流程图
            [defined] => 
            [title] => ECMS站点API程序执行流程图
            [keywords] => ecms工作原理,ecms执行流程
            [description] => 讲解ECMS程序基本执行原理
            [content] => ...
            [image] => 
            [edit_time] => 1543843423
            [click] => 0
            [sort] => 1
            [pv] => 2620
            [cat_unique_id] => 快速上手
            [cat_name] => 快速上手
            [category] => doc
            [article_url] => /快速上手/程序执行流程图-article.html
            [category_url] => /快速上手/p1-articles.html
            [category_info] => Array
                (
                    [cat_id] => 3
                    [category] => doc
                    [parent_id] => 1
                    [unique_id] => 快速上手
                    [cat_name] => 快速上手
                    [title] => 快速上手
                    [keywords] => 
                    [description] => 
                    [content] => 
                    [sort] => 0
                    [category_url] => /快速上手/p1-articles.html
                )

            [last_article] => Array
                (
                    [id] => 6
                    [cat_id] => 3
                    [filename] => 数据库字典
                    [defined] => 
                    [title] => ECMS-API客户端数据库字典
                    [keywords] => ecms数据库字典
                    [description] => ...
                    [content] => ...
                    [image] => 
                    [edit_time] => 1543844080
                    [click] => 0
                    [sort] => 0
                    [pv] => 1070
                    [article_url] => /数据库字典-article.html
                    [category_url] => /p1-articles.html
                )

            [next_article] => Array
                (
                    [id] => 9
                    [cat_id] => 3
                    [filename] => htaccess格式示例
                    [defined] => 
                    [title] => ECMS站点重写文件apache-htaccess讲解与示例
                    [keywords] => ecms-apache-htaccess
                    [description] => ...
                    [content] => ...
                    [image] => 
                    [edit_time] => 1543843353
                    [click] => 0
                    [sort] => 0
                    [pv] => 1120
                    [article_url] => /htaccess格式示例-article.html
                    [category_url] => /p1-articles.html
                )

            [content_description] => ...
        )

)