PHPCMS的使用
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHPCMS的使用相关的知识,希望对你有一定的参考价值。
1.下载安装phpcms
下载完后解压将install_packages上传到服务器并重命名为phpcms_test:
更改目录文件系统权限:
chmod -R 777 phpcms_test
配置nginx访问:
server {
root C:/Users/liudaoqiang/project_test/phpcms_test/;
index index.html index.php;
server_name dev.phpcms_test.com;
# set $yii_bootstrap "index.html";
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index $yii_bootstrap;
try_files $uri $uri/ $yii_bootstrap?$args;
if (!-e $request_filename) {
rewrite (.*) /index.php/$1;
}
}
location ~ ^/(protected|framework|nbproject|themes/\\w+/views) {
deny all;
}
location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\\.(js|css)?$ {
expires 7d;
}
#avoid processing of calls to unexisting static files by yii
location ~ \\.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \\.php$ {
fastcgi_split_path_info ^(.+\\.php)(.*)$;
#let yii catch the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
#fastcgi_next_upstream error timeout invalid_header http_500 http_503 http_404;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
location ~ /\\.ht {
deny all;
}
}
配置hosts文件:
127.0.0.1 dev.phpcms_test.com
启动php-fpm及nginx:
start nginx
nginx -s reload
访问http://dev.phpcms_test.com/install/install.php进入安装程序:
登录后台管理系统:
进入前台首页:
2.phpcms模板标签
pc标签:
{pc:content action="lists" catid="25" num="20" page="$_GET[page]" return="data"}
<ul>
{loop $data $n $r}
<li><a href="{$r[url]}">{$r[title]}</a></li>
{/loop}
</ul>
{/pc}
json工具标签:
{pc:json url="http://www.phpcms.cn/12.php" cache="86400"}
<ul>
{loop $data $key $val}
<li><a href="{$val[url]}">{$val[‘title‘]}</a></li>
{/loop}
</ul>
{/pc}
xml工具标签:
{pc:xml url="http://www.phpcms.cn/12.php" cache="86400"}
<ul>
{loop $data $key $val}
<li><a href="{$val[url]}">{$val[‘title‘]}</a></li>
{/loop}
</ul>
{/pc}
get标签:
{pc:get sql="SELECT * FROM phpcms_member" cache="3600" page="$page" dbsource="discuz" return="data"}
<ul>
{loop $data $key $val}
{$val[username]}<br />
{/loop}
</ul>
{$pages}
{/pc}
例:评论模块获取评论列表并展示:
{pc:comment action="lists" commentid="$commentid"}
<ul>
{loop $data $key $val}
<li> {$val[url]}于{format::date($val[creat_at], 1)}发布,他支持{direction($v[direction])}<br>{$val[content]}</li>
{/loop}
</ul>
{/pc}
例:获取会员模块的收藏文章列表:
{pc:member action="favoritelist" userid="$userid" order="id DESC" num="10"}
<ul class="title-list">
{loop $data $k $v}
<li>·<a href="{$v[‘url‘]}" target="_blank">{$v[‘title‘]}</a><span><em>{format::date($v[‘adddate‘], 1)}</em> </span></li>
{/loop}
</ur>
{/pc}
3.phpcms的二次开发
phpcms的目录结构:
phpcms的ur访问:
系统类库与函数库调用:
?>
static $configs = array();
if (!$reload && isset($configs[$file])) {
if (empty($key)) {
return $configs[$file];
} elseif (isset($configs[$file][$key])) {
return $configs[$file][$key];
} else {
return $default;
}
}
$path = CACHE_PATH.‘configs‘.DIRECTORY_SEPARATOR.$file.‘.php‘;
if (file_exists($path)) {
$configs[$file] = include $path;
}
if (empty($key)) {
return $configs[$file];
} elseif (isset($configs[$file][$key])) {
return $configs[$file][$key];
} else {
return $default;
}
}
以上是关于PHPCMS的使用的主要内容,如果未能解决你的问题,请参考以下文章