您的位置:首页 > 编程语言 > PHP开发

PHPCMS建站 - 随手记

2015-10-12 12:52 531 查看

(仅记录,大概整理一下,不想花太多时间在博客上)


1.PHPCMS去掉后台登录验证码

路径(后台程序文件):\phpcms\modules\admin\index.php  注释掉33/35/36行

 


 

路径(前台模版):\phpcms\modules\admin\templates\login.tpl.php   38行

注释:如图

 

 


 

 

2.PHPCMS去除后台首页(快捷方式、授权信息等)

\phpcms\modules\admin\templates\main.tpl.php 

 

授权信息105-112行

PHPCMS系统开发团队 92-103行

 

4.PHPCMS验证码文件

Checkcode.php

 

缩略图<img src="{thumb($r[thumb],265,155)}" alt="{$r[title]}">

分页<div id="pages" class="tc text-c">{$pages}</div>

 

{if $catid=="15"}{$CATEGORYS[$catid][catname]}{elseif $catid=="40"}{elseif $catid=="41"}{$CATEGORYS[$catid][catname]}{else}{/if}

 

内容页显示所在栏目的父级栏目名{$CATEGORYS[$CAT[parentid]][catname]}

频道页列表页显示所在栏目的父级栏目名{$CATEGORYS[$catid][catname]}

 

首页显示标题所在栏目

<!-- {php $subid = $r[catid]}                             [{$CATEGORYS[$subid][catname]}] -->

来源:{$copyfrom}

发布时间:{$inputtime}

内容页点击量:<i id="hits"></i>

<scriptlanguage="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>

 

上一篇、下一篇:

<a href="{$previous_page
<a href="{$next_page[url]}"><b>下一篇 : </b>{$next_page[title]}</a>

 

内容页分页:<div id="pages" class="text-c">{$pages}</div>

 

点击次数排序:yesterdayviews 

 

推荐位
{pc:content action="position" posid="18" thumb="1" order="listorder DESC" num="4"}
<ul>
{loop $data $key $val}
<li><a href="{$val['url']}">{if $val[thumb]}<img src="{thumb($val[thumb],90,90)}" width="90" height="90"/>{/if}</a></li>
<li><a href="{$val['url']}">{$val['title']}</a>{date('Y-m-d H:i:s',$val[inputtime])}</li>
{/loop}
</ul>
{/pc}

列表页内容页调用栏目所在的顶级栏目名{$CATEGORYS[$top_parentid][catname]}

摘要{str_cut($r[description],140)}

{str_cut($r[description],140)}    超过140用“…”代替并隐藏。

{str_cut($r[description],140),’’}    超过140,不显示“…”直接隐藏。

{str_cut($r[description],140),’...’} 超过140,隐藏并用“…”代替显示。

 

时间调用

{date('Y-m-d',$r[inputtime])} 内容发布时间

{date('Y-m-d',$r[updatetime])} 内容更新时间

{date('Y-m-d H:i:s',$r[inputtime])}    时间显示时分秒

 

 

文章从指定位置开始调用起始位置为5,调用3条

 

{pc:content action="position" posid="27" order="listorder DESC" num="3" start="5"}

{loop $data $r}

{str_cut($r[description],115)}...

{/loop}

{/pc}

 

 

调用指定栏目的名称

{$CATEGORYS[22]['catname']}

 

 

 

频道页面调用文章点击量及评论数

{pc:content action="lists" catid="$v[catid]" num="5" order="id 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));}
<li><a href="{$v}" target="_blank"{title_style($v[style])}>{$v[title]}</a>点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
{/pc}

 

首页调用文章点击量及评论数

{pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}
<ul class="list lh24 f14">
{loop $info $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].'-'.$modelid));}
<li>·<a href="{$v['url']}" target="_blank" title="{$v['title']}"{title_style($v[style])}>{str_cut($v['title'],40)}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
</ul>
{/pc}

 

 

推荐位调用文章点击量及评论数

{pc:content action="position" posid="2" order="listorder DESC" num="4"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}
{loop $data $r}
{php $category = $categorys[$r[catid]];}
{php $modelid = $category['modelid'];}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$r[catid].'-'.$r[id].'-'.$modelid));}
<h4 class="blue"><a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</h4>
<p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)}</p>
<div class="bk20 hr"><hr /></div>
{/loop}
{/pc}

 


列表页调用文章点击量及评论数

{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}
{loop $data $r}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));}
<li><span class="rt">{date('Y-m-d H:i:s',$r[inputtime])}</span>·<a href="{$r[url}" target="_blank"{title_style($r[style])}>{$r[title]}</a> 点击:{$views} 评论数:{if $comment_total}{$comment_total} {else}0{/if}</li>
{/loop}
{$pages}
{/pc}

 

[url=http://www.youpinzhiyuan.com/jishuzhidao/32.html]http://www.youpinzhiyuan.com/jishuzhidao/32.html" target=_blank>}"><b>上一篇 : </b>{$previous_page[title]}</a>

<a href="{$next_page[url]}"><b>下一篇 : </b>{$next_page[title]}</a>

 

内容页分页:<div id="pages" class="text-c">{$pages}</div>

 

点击次数排序:yesterdayviews 

 

推荐位
{pc:content action="position" posid="18" thumb="1" order="listorder DESC" num="4"}
<ul>
{loop $data $key $val}
<li><a href="{$val['url']}">{if $val[thumb]}<img src="{thumb($val[thumb],90,90)}" width="90" height="90"/>{/if}</a></li>
<li><a href="{$val['url']}">{$val['title']}</a>{date('Y-m-d H:i:s',$val[inputtime])}</li>
{/loop}
</ul>
{/pc}

列表页内容页调用栏目所在的顶级栏目名{$CATEGORYS[$top_parentid][catname]}

摘要{str_cut($r[description],140)}

{str_cut($r[description],140)}    超过140用“…”代替并隐藏。

{str_cut($r[description],140),’’}    超过140,不显示“…”直接隐藏。

{str_cut($r[description],140),’...’} 超过140,隐藏并用“…”代替显示。

 

时间调用

{date('Y-m-d',$r[inputtime])} 内容发布时间

{date('Y-m-d',$r[updatetime])} 内容更新时间

{date('Y-m-d H:i:s',$r[inputtime])}    时间显示时分秒

 

 

文章从指定位置开始调用起始位置为5,调用3条

 

{pc:content action="position" posid="27" order="listorder DESC" num="3" start="5"}

{loop $data $r}

{str_cut($r[description],115)}...

{/loop}

{/pc}

 

 

调用指定栏目的名称

{$CATEGORYS[22]['catname']}

 

 

 

频道页面调用文章点击量及评论数

{pc:content action="lists" catid="$v[catid]" num="5" order="id 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));}
<li><a href="{$v}" target="_blank"{title_style($v[style])}>{$v[title]}</a>点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
{/pc}

 

首页调用文章点击量及评论数

{pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}
<ul class="list lh24 f14">
{loop $info $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].'-'.$modelid));}
<li>·<a href="{$v['url']}" target="_blank" title="{$v['title']}"{title_style($v[style])}>{str_cut($v['title'],40)}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
</ul>
{/pc}

 

 

推荐位调用文章点击量及评论数

{pc:content action="position" posid="2" order="listorder DESC" num="4"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}
{loop $data $r}
{php $category = $categorys[$r[catid]];}
{php $modelid = $category['modelid'];}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$r[catid].'-'.$r[id].'-'.$modelid));}
<h4 class="blue"><a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</h4>
<p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)}</p>
<div class="bk20 hr"><hr /></div>
{/loop}
{/pc}

 


列表页调用文章点击量及评论数

{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}
{loop $data $r}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));}
<li><span class="rt">{date('Y-m-d H:i:s',$r[inputtime])}</span>·<a href="{$r[url}" target="_blank"{title_style($r[style])}>{$r[title]}</a> 点击:{$views} 评论数:{if $comment_total}{$comment_total} {else}0{/if}</li>
{/loop}
{$pages}
{/pc}

 

[url=http://www.youpinzhiyuan.com/jishuzhidao/32.html]http://www.youpinzhiyuan.com/jishuzhidao/32.html
 phpcms相关

 

多栏目调用&多推荐位调用

调用需求:文章范围为59 60 61三个栏目,并且推送到了27 和28两个推荐位;从第三条开始,连续调用7篇文章。
{pc:get sql="SELECT * FROM v9_news WHERE id IN (SELECT id FROM v9_position_data WHERE posid in(27,28) and catid in(59,60,61)) order by listorder DESC" cache="3600" start="3" num="7" return="data" }
{loop $data $n $r}
<li>·<a target="_blank" href='{$r[url]}' title="{$r[title]}" style="color:Black;">{str_cut($r[title],22,'')}</a></li>
{/loop} {/pc}

 

在文章面前显示文章类别

{pc:content action="lists" catid="79" order="listorder DESC" num="14" }
<?php $TYPE = getcache('type_content','commons');?>
{loop $data $n $r}
<li>{if $TYPE[$r[typeid]][name]}<span style="color:#CC6600">[ {$TYPE[$r[typeid]][name]}] </span>{/if}<a href="{$r['url']}"{title_style($r[style])}title="{$r['title']}" target="_blank">{str_cut($r[title],33,'')}</a></li>
{/loop}{/pc}

 

列表页完美支持自定义段调用 

(lastkaixin){pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}
{loop $data $r}
<a href="{$r[url]}">[{$r['字段名']}]> {$r[title]}</a>
{/loop}
<div class="pagebar">
{$pages}</div>
{/pc}

 

 

 

 

 

同时调用多个栏目的文章,文章前显示栏目名称

{pc:get sql="SELECT * FROM v9_news WHERE catid IN (61,62,63,64,65) order by id DESC" num="10" return="data" }
{loop $data $n $r}
<LI><SPAN><a href="{$CATEGORYS[$r[catid]][url]}">[{$CATEGORYS[$r['catid']]['catname']}]</A></SPAN><A href="{$r[url]}" target=_blank>{str_cut($r[title],27,'')}</A></LI>
{/loop} {/pc}

 

 

当天文章后面显示 new图标
{if time()-$r[updatetime]<24*3600}<img src="/image/new.gif">{if time()-$r[updatetime]<24*3600}<img src="/image/new.gif">{/if}
如果是三天内的文章: 3*24*3600

 

同时调用多个推荐位的内容(非sql)
25,26,20,21 就是推荐位id{php $where = "catid IN (25,26,20,21) "}
{pc:content action="position" posid="2" order="listorder DESC" where="$where" moreinfo="1" num="2"}
{loop $data $r}
<a href="{$r[url}" title="{$r[title]}">{str_cut($r[title],36,'')}</a><br>
{str_cut($r[description],112)}
<div class="bk20 hr"><hr /></div>
{/loop}
{/pc}

 

在首页调用单网页的数据

做企业网站灰常有用(感谢monitorli兄弟 PM)2011.10.19
{pc:get sql="SELECT * FROM v9_page where catid=2" page="$page"}
{loop $data $r}
{str_cut(strip_tags($r[content]), 345,'')}
{/loop}
{/pc}

 

 

多种if else判断

{pc:content action="lists" catid="42" order="id DESC" num="5" }
{loop $data $n $r}

<li>·<a href="{$r['url']}" title="{$r['title']}"{title_style($r[style])}>{str_cut($r[title],39,'')}</a> {if time()-$r[updatetime]<24*180*60}<img src='/image/new.gif' />{else}<span class="ind_tim2">{date('m-d',$r[inputtime])}</span>{/if}</li>

{/loop}
{/pc}

 

网站搬家http://www.youpinzhiyuan.com/jishuzhidao/2012/1215/166.html

 

1。在新的主机空间把phpcms安装好。
新安装的版本一定要和准备搬迁的版本一样,否则可能会出现问题。
在新安装时要把除数据库配置以外的各种设置和原来的一样,不一样也没问题,到时把原来主机的config.inc.php文件拷贝一份再修改一下就OK了。
还有新安装的数据表前缀要和旧的一样,否则到时保留旧的设置,因为前缀不一样就不是覆盖而是增加了旧前缀的表。
2。用phpcms自带的数据库备份工具把数据库备份,然后上传到新空间相同位置!
3。你把原来的include/config.inc.php拷贝下来,把数据库配置改成新空间的,其它的不要改动。
还有一个data/config.js这个东西。它的设置要求和config.inc.php里面对应一致!
所以也可以把原来的替换新安装的,两个都替换。这样会少很多莫名其妙的问题。
如果不会配置数据库的就把新的config.inc.php文件和旧的对比一下,把旧文件下面三项换成新的。然后修改后的旧文件上传到空间覆盖新的。
define('DB_HOST', 'localhost'); //数据库服务器主机地址

define('DB_USER', 'root'); //数据库帐号

define('DB_PW', '111111'); //数据库密码
复制代码
4。把你原来站的uploadfile(图片之类的附件)上传到新空间。
5。把皮肤文件上传到新空间,包括素材文件夹(没修改过皮肤的就没这个必要)
6。把自己修改过的文件上传到新空间覆盖没改修过的。
7。登陆新空间的后台,用数据库工具恢复数据库。
8。更新缓存,更新皮肤,生成相应页面!

 

 

默认自动分页方式的修改方法

phpcms\modules\content\fields\pages\form.inc.php

phpcms\modules\special\templates\content_add.tpl.php  76 

 


\phpcms\modules\special\templates\content_edit.tpl.php 75

 


 

按比例等宽完美缩略图方案
<img src="{thumb($r[thumb],200,0)}"  alt="{$r[title]}"/>

第一步:
找到 phpcms\libs\functions\global.func.php 的thumb函数下的

if($width>=$width_t || $height>=$height_t) return $imgurl;
加上两个if:

if ($height==0) {
           $scale=$width_t/$width;
           $height=round($height_t/$scale);
        }
if ($width==0) {
           $scale=$height_t/$height;
           $width=round($width_t/$scale);
        } 



还有一个问题:

PHPCMS V9生成的缩略图有黑边,当原图比例与缩略图比例相同时,生成的缩略图比例不正确,有一块黑边 

是 phpcms\libs\classes\image.class.php 中的 getpercent 函数的问题

第65、66两行的变量赋值错了
// 原来的

$h = $dstw;
$w = $dsth;
修改为如下后正常
//修改后
$w = $dstw;
$h = $dsth;
复制代码手工改了这个文件后,把原来已生成的缩略图删除,再生成一下页面
 


 

 

 

 

 

 

调用指定推荐位:

{pc:content  action="position" posid="19" start="2" order="listorder ASC" thumb="1" num="2"} 

{loop $data $r}

<li class="fl">

        <a href="{$r['url']}" class="w375 br2 oh tst" title="{$r['title']}">

        <div class="h205 w100p tc">

         <img src="{thumb($r['thumb'],320,0)}" alt="{$r['title']}" class="pic_c_m br2">

         <i class="w100p h100p pic_c_m"></i>

        </div>

        <span class="db tc fs14 tst">{$r['title']}</span>

    </a>

        </li>

   {/loop} 

{/pc}

 


 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息