本篇文章文章内容整理来源于网络!
PHPCMS作为普通企业展示站还是非常不错的,静态化做的也是非常好,速度也挻快的。标签调用也是一学就懂。接触过几款cms, php语言类型的话,wordpress做博客最好,国内外主题资源多,网上相关教程也多,运行速度和效率有待加强,静态化只能借住插件;dede是目前国内最多人使用的,中小城市里很多公司的网站都是用dede做的,论坛活跃,很多问题都能得到解决,个人感觉后台不够人性化美观度有待加强,效率一般在数据量多的时候速度就不行了;phpcms是让人又爱又恨的,v9开始后台届面美观体验度较好,相比 wordpress 和dede 数据处理能力是最快最强的,站群功能也是一大亮点,但是目前对于phpcms的文档资源还是太少,官方论坛基本都快成鬼区了,有很多问题得不到解决。如果有需要二开的地方太多还是建议用dede,基本上有问题随便一发网上成堆的资源。
文件路径调用
1 2 3 | {CSS_PATH}CSS文件路径,对应http://您的域名/statics/css/ {JS_PATH}JS文件路径,对应http://您的域名/statics/js/ {IMG_PATH}图片文件路径,对应http://您的域名/statics/images/ |
模版调用
1 2 | {template "模版目录名"," 模版 文件名"} {template "content","footer"}调用content目录下footer模版 |
常用字段(其它字段可查看模型的所有字段)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | catid="$catid" 当前栏目ID action="category" 主要栏目名称调用等 action="lists" 主要用于列表调用等 action="hits" 调用排行等 action="position" 主要用于推荐位列表等 posid="9" 推荐位ID="9" num="10" 数据调用数量="10" page="$page" 调用分页 cache="3600" 缓存="3600″毫秒 {$r[title]}文章标题可增加截取 {$r[url]}链接 {$r[description]}摘要 {thumb($r[thumb],200,200)}略缩图200px*200px {$v[inputtime])}日期 {date('Y-m-d H:i:s',$v[inputtime])} 时间格式化调用 年-月-日 时:分:秒 {date('m/d',$v[inputtime])} 时间格式化调用 月/日,其它组合类推 {str_cut($v[字段名],30,…)} 超出30字符后用...代替,注意一个汉字等于3字符 自定义字段{$v[自定义字段]} 主表字段加上 moreinfo="1" {if $n%3 ==0}需要出现的内容{/if} 判断语句,文章、列表分组或每3篇文章出现一次 |
文件或栏目排序方式
1 2 3 4 5 6 7 | order="listorder ASC" 默认排序正序排序(栏目一般用这种,后台可以设置手动排序,比如1,2,3文章,可以手动调用为2,3,1/3,1,2/2,1,3顺序等等,以下简称手动) order="listorder DESC" 默认排序逆序排序 (文章一般用这种,后台可以设置手动排序) order="id ASC" 按ID正序排序 (设置后,后台手动排序不能生效) order="id DESC" 按ID逆序排序 (设置后,后台手动排序不能生效) order="inputtime ASC"按发布时间正序排序 order="inputtime DESC"按发布时间逆序排序 order="weekviews DESC"按点周击量逆序排序 |
网页头部部分
1 2 3 | {if isset($SEO['title']) && !empty($SEO['title'])}{$SEO['title']}{/if}{$SEO['site_title']} 网页标题 <meta name="keywords" content="{$SEO['keyword']}"> 网页关键字 <meta name="description" content="{$SEO['description']}"> 网页描述 |
首页导航代码(附带选中栏目高亮完美解决方法,添加active类,样式部分自行定义)
1 2 3 4 5 6 7 8 | {pc:content action="category" catid="0" num="25" siteid="$siteid" order="listorder ASC"} <ul> <li><a href="{siteurl($siteid)}" {if !$catid}class="active"{/if}>首页</a></li> {loop $data $r} <li><a href="{$r[url]}" {if !$catid}class="active"{/if}>{$r[catname]}</a></li> {/loop} </ul> {/pc} |
首页导航代码(栏目包函子栏目一起调用,$k和$r位置不能变)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | {pc:content action="category" catid="0" num="25" siteid="$siteid" order="listorder ASC"} <ul> <li><a href="{siteurl($siteid)}">首页</a></li> {loop $data $k $r} <li><a href="{$r[url]}">{$r[catname]}</a> {pc:content action="category" catid="$k" num="25" siteid="$siteid" order="listorder ASC"} <ul> {loop $data $v} <li><a href="{$v[url]}">{$v[catname]}</a></li> {/loop} </ul> {/pc} </li> {/loop} </ul> {/pc} |
频道页、列表页、内容页当前父栏目所有子栏目名称调用(附选中栏目高亮完美解决方法)
1 2 3 4 5 | {pc:content action="category" catid="$catid" num="5" siteid="$siteid" order="listorder ASC"} {loop $data $r} <li><a href="{$r[url]}" {if $top_parentid == $r[catid]||$catid==$r[catid]||$parentid==$r[catid]}class="active"{/if}>{$r[catname]}</a></li> {/loop} {/pc} |
网站公告模块
1 2 3 4 5 | {pc:announce action="lists" siteid="$siteid" num="5"} {loop $data $r} <a href="{APP_PATH}index.php?m=announce&c=index&a=show&aid={$r['aid']}">{$r['title']}</a> {/loop} {/pc} |
推荐位调用(posid=""填推荐位序号,后台可以查看)
1 2 3 4 5 | {pc:content action="position" posid="" order="listorder DESC " num="1" cache="3600"} {loop $data $r} <a href="{$r[url]}">{$r[title]}</a> {/loop} {/pc} |
基本文章调用
(如需分页请加上 page="$page" 如从第2条文件开始调用25条请加上 start="2" 或者limit="1,25--")
1 2 3 4 5 | {pc:content action="lists" catid="$catid" siteid="$siteid" num="25" order="listorder DESC"} {loop $data $r} <a href="{$r[url]}">{$r[title]}</a> {/loop} {/pc} |
友情链接调用
1 2 3 4 5 | {pc:link action="type_list" siteid="$siteid" linktype="1" order="listorder DESC" num="24" return="pic_link"} {loop $pic_link $v} <a href="{$v[url]}" target="_blank"><img src="{$v[logo]}" alt="{$v[name]}">{$v[name]}</a> {/loop} {/pc} |
频道或列表文章排行
(首页调用需指定栏目ID要不然会空白,order="weekviews DESC"星期点击排行,order="views DESC"总点击排行,order="monthviews"月排行用 ,order="daythviews" 日排行,年排行排行用单词类推)
1 2 3 4 5 6 | {pc:content action="hits" catid="$catid" siteid="$siteid" order="weekviews DESC" num="10"} <?php $n=0;++$n; ?> {loop $data $r} {$n}-<a href="{$r[url]}">{$r[title]}</a> {/loop} {/pc} |
调用 news 模型下最新文章(其实也就是按ID逆顺)
1 2 3 4 5 | {pc:get sql="SELECT * FROM `v9_news` Order by id DESC " num="10"} {loop $data $r} <a href="{$r[url]}">{$r[title]}</a> {/loop} {/pc} |
文章浏览和评论量调用(首页)
1 2 3 4 5 6 7 8 9 10 | {pc:content action="lists" catid="1" siteid="$siteid" num="25" order="listorder DESC"} {php $categorys = getcache('category_content_'.$siteid,'commons');} {loop $data $v} {php $category = $categorys[$v[catid]];} {php $modelid = $category['modelid'];} {php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; } {php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$siteid));} <a href="{$v[url]}">{$v[title]} - 点击量:{$views}- 评论量:{if $comment_total}{$comment_total}{else}0{/if}</a> {/loop} {/pc} |
文章浏览量和评论量调用(频道页和列表页调用)
1 2 3 4 5 6 7 | {pc:content action="lists" catid="$catid" siteid="$siteid" num="25" order="listorder DESC"} {loop $data $v} {php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; } {php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));} <a href="{$v[url]}">{$v[title]} - 点击量:{$views}- 评论量:{if $comment_total}{$comment_total}{else}0{/if}</a> {/loop} {/pc} |
文章浏览量
(内容页调用,需引用jq库,提供要用原生JS的方法,api返回值是用JQ选中ID为hits然后写入数值)
点击量:
1 2 | <span id="hits"></span> <script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script> |
文章浏览量 (不引用JQ库)
1 2 3 | {php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$id)); $views = $_r[views]; } 点击量: {$views} <script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script> |
文章标题前面调用文章所在栏目名称
1 2 3 | {$CATEGORYS[$v[catid]][catname]} 频道页调用($v为调用文章时你使用的循环标签) {$CATEGORYS[$catid][catname]} 列表页调用(如所有文章都在本列表下可直接用$catid,不全在用频道页的) {$CATEGORYS[22][catname]} 调用栏目为22的栏目名称 |
关键字调用(关键字格式化explode(' ',$v[keywords]);关键字用空格间隔,explode(',',$v[keywords]);关键字用逗号间隔;
{php $keywords = explode(' ',$v[keywords]);}
关键字:
{loop $keywords $keyword}
{$keyword}
{/loop}
单页调用/内容页相关调用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | {$title}标题 {$inputtime}发布时间 {$updatetime}更新时间 {catpos($catid)} 当前位置 {$pages}内容分页 {$CAT[catname]}当前栏目 {$content}文章内容 内容页组图调用 {loop $pictureurls $pic_k $r} <img src="{thumb($r[url]}"/> {/loop} 上一篇:<a href="{$previous_page[url]}">{$previous_page[title]}</a> 下一篇:<a href="{$next_page[url]}">{$next_page[title]}</a> 调用评论 {if $allow_comment && module_exists('comment')} <iframe src="{APP_PATH}index.php?m=comment&c=index&a=init&commentid={id_encode("content_$catid",$id,$siteid)}&iframe=1" width="100%" height="100%" id="comment_iframe" frameborder="0" scrolling="no"></iframe> {/if} |
相关文章
1 2 3 4 5 6 7 | {pc:content action="relation" relation="$relation" id="$id" catid="$catid" num="5" keywords="$rs[keywords]"} {if $data} {loop $data $r} <a href="{$r[url]}" target="_blank">{$r[title]}</a>{date('Y-m-d',$r[inputtime])} {/loop} {/if} {/pc} |
因目前接触较多的为文章系统,其它模型请参考官方文档,本文会随时间慢慢完善。如果有不知道的地方多去看看数据表的结构大多也能看明白了。
技术有限,本篇所有调用如有错误请指正,在PHPCMS程序版本:Phpcms V9.6.0 Release 20151225 下2016年2月26日全部测试。