
当前页可用变量有$category,$article,$prev_article,$next_article,这三个变量都是模型对象,取值时可以直接把它当成数组用。
输出$category内部的值
$category代表当前文章分类
{$category.id} <!--输出分类 id-->{$category.parent_id} <!--输出分类父级分类 id-->{$category.name} <!--输出分类名称-->{$category.description} <!--输出分类描述-->{$category.seo_title} <!--输出分类seo标题-->{$category.seo_keywords} <!--输出分类 seo 关键字-->{$category.seo_description} <!--输出分类 seo 描述-->以上的值也可以当成 php 变量直接输出,这里只演示一下怎么输出 id 属性
<php>echo $category['id']; /*输出分类 id*/</php>
输出$article内部的值
$article代表当前文章
{$article.id} <!--输出文章id-->{$article.is_top} <!--输出文章置顶状态,1:置顶;0:不置顶-->{$article.recommended} <!--输出文章推荐状态,1:推荐;0:不推荐-->{$article.post_hits} <!--输出文章查看数-->{$article.post_like} <!--输出文章点选数-->{$article.comment_count} <!--输出文章评论数-->{$article.create_time} <!--输出文章创建时间-->{$article.update_time} <!--输出文章更新时间-->{$article.published_time} <!--输出文章发布时间-->{$article.post_title} <!--输出文章标题-->{$article.post_keywords} <!--输出文章关键字,以英文逗号隔开-->{$article.post_excerpt} <!--输出文章摘要-->{$article.post_content} <!--输出文章内容-->以上的值也可以当成 php 变量直接输出,这里只演示一下怎么输出 id 属性
<php>echo $article['id']; /*输出分类 id*/</php>
$prev_article代表前上一篇文章,属性列表和$article一样,这里就不在举例$next_article代表前下一篇文章,属性列表和$article一样,这里就不在举例
调用文件缩略图
<notempty name="article.more.thumbnail">
<img src=" {:cmf_get_image_url($article.more.thumbnail)}"/></notempty>调用文章的相册
<!--调用文章的相册--><notempty name="article.more.photos">
<foreach name="article.more.photos" item="photo">
<img src=" {:cmf_get_image_url($photo.url)}" alt={$photo.name}/>
</foreach></notempty>调用文章的附件
<!--调用文章的附件--><notempty name="article.more.files">
<foreach name="article.more.files" item="file">
<a href="{:cmf_get_file_download_url($file.url)}" title={$file.name}>下载文件</a>
</foreach></notempty>文章 SEO
<head>
<title>{$article.post_title}</title>
<meta name="keywords" content="{$site_info.site_seo_keywords|default=''}"/>
<meta name="description" content="{$site_info.site_seo_description|default=''}">
<!--省略...--></head>创建文章页模板
在public/themes/quick_start/portal目录下创建article.html文件,内容如下:
<!DOCTYPE html><html><head>
<title>{$article.post_title}</title>
<meta name="keywords" content="{$site_info.site_seo_keywords|default=''}"/>
<meta name="description" content="{$site_info.site_seo_description|default=''}">
<include file="public@head"/>
<style>
#article_content img {
height: auto !important;
max-width: 100%;
}
#article_content {
word-wrap: break-word;
}
</style></head><body class="body-white"><include file="public@nav"/><div class="container">
<div class="row">
<div class="col-md-9">
<div class="tc-box article-box">
<h2>{$article.post_title}</h2>
<div class="article-infobox">
<span>{:date('Y-m-d H:i',$article.published_time)} by {$article.user.user_nickname}</span>
<span>
<a href="javascript:;"><i class="fa fa-eye"></i><span>{$article.post_hits}</span></a>
<a href="{:url('portal/Article/doLike',array('id'=>$article['id']))}" class="js-count-btn"><i
class="fa fa-thumbs-up"></i><span class="count">{$article.post_like}</span></a>
<a href="{:url('user/favorite/add')}"
class="js-favorite-btn"
data-title="{:base64_encode($article.post_title)}"
data-url="{:cmf_url_encode('portal/Article/index',array('id'=>$article['id']))}"
data-table="portal_post"
data-id="{$article['id']}"
>
<i class="fa fa-star-o"></i>
</a>
</span>
</div>
<hr>
<div id="article_content">
{$article.post_content}
</div>
</div>
</div>
<div class="col-md-3">
</div>
</div></div><include file="public@footer"/><include file="public@scripts"/></body></html>添加模板配置文件
在public/themes/quick_start/portal目录下创建article.json文件,内容如下:
{
"name": "文章页",
"action": "portal/Article/index",
"description": "文章页模板文件",
"order": 10.0,
"more": {
"vars": {
}
}}更新模板
至此门户文章页模板制作完成。
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, LeCMS, ClassCMS, Fastadmin, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。


