
thinkcmf模板
thinkcmf5评论显示几天前,几小时前,几分钟前的代码
博客 • maomao 发表了文章 • 0 个评论 • 1613 次浏览 • 2019-04-08 15:41
一.在simplewind\cmf\common.php加入公共方法
/*二.前台模板调用
* 时间戳用来转成xx前
*/
function ChangeTime($time)
{
$time = time() - $time;
if (is_numeric($time)) {
$value = array(
"years" => 0, "days" => 0, "hours" => 0,
"minutes" => 0, "seconds" => 0,
);
if ($time >= 31556926) {
$value["years"] = floor($time / 31556926);
$time = ($time % 31556926);
$t = $value["years"] . '年前';
} elseif (31556926 > $time && $time >= 86400) {
$value["days"] = floor($time / 86400);
$time = ($time % 86400);
$t = $value["days"] . '天前';
} elseif (86400 > $time && $time >= 3600) {
$value["hours"] = floor($time / 3600);
$time = ($time % 3600);
$t = $value["hours"] . '小时前';
} elseif (3600 > $time && $time >= 60) {
$value["minutes"] = floor($time / 60);
$time = ($time % 60);
$t = $value["minutes"] . '分钟前';
} else {
$t = $time . '秒前';
}
return $t;
} else {
return date('Y-m-d H:i:s', time());
}
}
{:ChangeTime($vo.download_time)}三.显示效果如下
thinkcmf5 nginx 伪静态报500错误
博客 • maomao 发表了文章 • 0 个评论 • 2449 次浏览 • 2019-03-09 12:25
1、绑定网站运行目录

2、填写伪静态规则:
PHP
[code]location / {[/code]
index index.php index.html index.htm;
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?s=$1;
}
}
location /api/ {
index index.php index.html index.htm;
if (!-e $request_filename)
{
rewrite ^/api/(.*)$ /api/index.php?s=$1;
}
}
location ~* \/upload\/.+\.(html|php)$ {
return 404;
}
location ~* ^\/plugins\/.+\.(html|php)$ {
return 404;
}
location ~* \/themes\/.+\.(html|php)$ {
return 404;
}

3、保存,OK!
thinkcmf模板开发教程之<八>thinkcmf5 后台搜索分页保持分页条件
博客 • maomao 发表了文章 • 0 个评论 • 3447 次浏览 • 2018-11-17 12:18
$params=$this->request->param();漂泊者博客原创,转载请标注出处!
// 查询状态为1的用户数据 并且每页显示10条数据
$users = Db::name('user')->where('user_email','like',"{$params['email']}%")->paginate(10);
// 把分页数据赋值给模板变量users
$this->assign('users', $users);
// 在 render 前,使用appends方法保持分页条件
$users->appends($params);
$this->assign('page', $users->render());//单独提取分页出来
// 渲染模板输出
return $this->fetch();
thinkcmf5自定义错误页面、成功页面及异常页面
博客 • maomao 发表了文章 • 0 个评论 • 1310 次浏览 • 2018-10-31 20:58
thinkcmf模板开发教程之<七>获取网站配置信息,后台设置网站设置信息
博客 • maomao 发表了文章 • 0 个评论 • 1591 次浏览 • 2018-09-24 22:06
后台设置网站设置信息:
<input type="text" class="form-control" id="input-com_user_integral" name="options[com_user_integral]" value="{$site_info.com_user_integral|default=''}">
获取网站配置信息:
cmf_get_option('site_info')['sensitive_word'];
thinkcmf模板开发教程之<六>如何修改增加后台左侧导航
博客 • maomao 发表了文章 • 0 个评论 • 2115 次浏览 • 2018-09-21 15:22
thinkcmf模板开发教程之<五>评论敏感词过滤方法
博客 • maomao 发表了文章 • 0 个评论 • 1637 次浏览 • 2018-09-21 09:30
下面给大家推荐两种敏感词过滤方法:
$badword = array(
'张三','张三丰','张三丰田'
);
$badword1 = array_combine($badword,array_fill(0,count($badword),'*'));
$bb = '我今天开着张三丰田上班';
$str = strtr($bb, $badword1);
echo $str;
$hei=array(
'中国',
'日本'
);
$blacklist="/".implode("|",$hei)."/i";
$str="中国一是一个很好的国家";
if(preg_match($blacklist, $str, $matches)){
print "found:". $matches[0];
} else {
print "not found.";
}
thinkcmf模板开发教程之<四>jquery动态往评论列表li中前添加和后追加
博客 • maomao 发表了文章 • 0 个评论 • 1586 次浏览 • 2018-09-19 22:10
一.前添加的jquery代码如下:
$(" <li class=\"comment-content\"><span class=\"comment-f\">#"+data.id+"</span><div class=\"comment-main\"><p><a class=\"address\" href=\"javascript:;\" rel=\"nofollow\" target=\"_blank\">"+data.user_nickname+"</a><span class=\"time\">("+data.add_time+")</span><br>"+data.content+"</p></div></li>").prependTo("#comment_list");二.后追加的jquery的代码如下:
$("#comment_list").append(" <li class=\"comment-content\"><span class=\"comment-f\">#"+data.id+"</span><div class=\"comment-main\"><p><a class=\"address\" href=\"javascript:;\" rel=\"nofollow\" target=\"_blank\">"+data.user_nickname+"</a><span class=\"time\">("+data.add_time+")</span><br>"+data.content+"</p></div></li>");
三.给大写一个完整的jquery前添加,后追加的案例如下:
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="./jquery-2.2.4.min.js">
</script>
<script type="text/javascript">
$(function(){
//获取按钮并设置点击事件
$("button").click(function(){
//获取输入框里面的值
var value = $("input[name = 'uname']").val();
//
switch ($(this).html()){
case "前添加":
//获取到ul并在其前面添加
//$("ul").prepend("<li>" + value +"</li>");
$("<li>" + value +"</li>").prependTo("ul");
break;
case "后追加":
$("ul").append("<li>" + value +"</li>");
//$("<li>" + value +"</li>").appendTo("ul");
break;
}
});
});
</script>
</head>
<body>
<h2>jquery 前追加和后追加</h2>
<ul>
<li>aaaa</li>
<li>bbbb</li>
<li>cccc</li>
</ul>
名称:<input type="text" name="uname" />
<button>前添加</button>
<button>后追加</button>
</body>
</html>
thinkcmf模板开发教程之<三>thinkcmf5模板中portal:articles标签不解析
博客 • maomao 发表了文章 • 0 个评论 • 4454 次浏览 • 2018-09-17 18:35
在使用thinkcmf5搭建自写主题的时候,有时候用portal:articles标签的时候会提示错误。
未定义数组索引 post_title
这种情况是没有写前置调用代码,在当前模板页面或公共头部模块页面添加代码:
<taglib name="app\portal\taglib\Portal"/>
thinkcmf模板开发教程之<二>动态循环输出轮播图
博客 • maomao 发表了文章 • 0 个评论 • 2303 次浏览 • 2018-09-17 15:39
<slides id="1">
<div class="item <if condition="($key == 0)">active</if>">
<a href="{$vo.url|default=''}" target="_blank" title="{$vo.title|default=''}" >
<img src="{:cmf_get_image_url($vo.image)}" alt="{$vo.title|default=''}" class="img-responsive"></a>
</div>
</slides>
thinkcmf5评论显示几天前,几小时前,几分钟前的代码
博客 • maomao 发表了文章 • 0 个评论 • 1613 次浏览 • 2019-04-08 15:41
一.在simplewind\cmf\common.php加入公共方法
/*二.前台模板调用
* 时间戳用来转成xx前
*/
function ChangeTime($time)
{
$time = time() - $time;
if (is_numeric($time)) {
$value = array(
"years" => 0, "days" => 0, "hours" => 0,
"minutes" => 0, "seconds" => 0,
);
if ($time >= 31556926) {
$value["years"] = floor($time / 31556926);
$time = ($time % 31556926);
$t = $value["years"] . '年前';
} elseif (31556926 > $time && $time >= 86400) {
$value["days"] = floor($time / 86400);
$time = ($time % 86400);
$t = $value["days"] . '天前';
} elseif (86400 > $time && $time >= 3600) {
$value["hours"] = floor($time / 3600);
$time = ($time % 3600);
$t = $value["hours"] . '小时前';
} elseif (3600 > $time && $time >= 60) {
$value["minutes"] = floor($time / 60);
$time = ($time % 60);
$t = $value["minutes"] . '分钟前';
} else {
$t = $time . '秒前';
}
return $t;
} else {
return date('Y-m-d H:i:s', time());
}
}
{:ChangeTime($vo.download_time)}三.显示效果如下
thinkcmf5 nginx 伪静态报500错误
博客 • maomao 发表了文章 • 0 个评论 • 2449 次浏览 • 2019-03-09 12:25
1、绑定网站运行目录

2、填写伪静态规则:
PHP
[code]location / {[/code]
index index.php index.html index.htm;
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?s=$1;
}
}
location /api/ {
index index.php index.html index.htm;
if (!-e $request_filename)
{
rewrite ^/api/(.*)$ /api/index.php?s=$1;
}
}
location ~* \/upload\/.+\.(html|php)$ {
return 404;
}
location ~* ^\/plugins\/.+\.(html|php)$ {
return 404;
}
location ~* \/themes\/.+\.(html|php)$ {
return 404;
}

3、保存,OK!
thinkcmf模板开发教程之<八>thinkcmf5 后台搜索分页保持分页条件
博客 • maomao 发表了文章 • 0 个评论 • 3447 次浏览 • 2018-11-17 12:18
$params=$this->request->param();漂泊者博客原创,转载请标注出处!
// 查询状态为1的用户数据 并且每页显示10条数据
$users = Db::name('user')->where('user_email','like',"{$params['email']}%")->paginate(10);
// 把分页数据赋值给模板变量users
$this->assign('users', $users);
// 在 render 前,使用appends方法保持分页条件
$users->appends($params);
$this->assign('page', $users->render());//单独提取分页出来
// 渲染模板输出
return $this->fetch();
thinkcmf5自定义错误页面、成功页面及异常页面
博客 • maomao 发表了文章 • 0 个评论 • 1310 次浏览 • 2018-10-31 20:58
thinkcmf模板开发教程之<七>获取网站配置信息,后台设置网站设置信息
博客 • maomao 发表了文章 • 0 个评论 • 1591 次浏览 • 2018-09-24 22:06
后台设置网站设置信息:
<input type="text" class="form-control" id="input-com_user_integral" name="options[com_user_integral]" value="{$site_info.com_user_integral|default=''}">
获取网站配置信息:
cmf_get_option('site_info')['sensitive_word'];
thinkcmf模板开发教程之<六>如何修改增加后台左侧导航
博客 • maomao 发表了文章 • 0 个评论 • 2115 次浏览 • 2018-09-21 15:22
thinkcmf模板开发教程之<五>评论敏感词过滤方法
博客 • maomao 发表了文章 • 0 个评论 • 1637 次浏览 • 2018-09-21 09:30
下面给大家推荐两种敏感词过滤方法:
$badword = array(
'张三','张三丰','张三丰田'
);
$badword1 = array_combine($badword,array_fill(0,count($badword),'*'));
$bb = '我今天开着张三丰田上班';
$str = strtr($bb, $badword1);
echo $str;
$hei=array(
'中国',
'日本'
);
$blacklist="/".implode("|",$hei)."/i";
$str="中国一是一个很好的国家";
if(preg_match($blacklist, $str, $matches)){
print "found:". $matches[0];
} else {
print "not found.";
}
thinkcmf模板开发教程之<四>jquery动态往评论列表li中前添加和后追加
博客 • maomao 发表了文章 • 0 个评论 • 1586 次浏览 • 2018-09-19 22:10
一.前添加的jquery代码如下:
$(" <li class=\"comment-content\"><span class=\"comment-f\">#"+data.id+"</span><div class=\"comment-main\"><p><a class=\"address\" href=\"javascript:;\" rel=\"nofollow\" target=\"_blank\">"+data.user_nickname+"</a><span class=\"time\">("+data.add_time+")</span><br>"+data.content+"</p></div></li>").prependTo("#comment_list");二.后追加的jquery的代码如下:
$("#comment_list").append(" <li class=\"comment-content\"><span class=\"comment-f\">#"+data.id+"</span><div class=\"comment-main\"><p><a class=\"address\" href=\"javascript:;\" rel=\"nofollow\" target=\"_blank\">"+data.user_nickname+"</a><span class=\"time\">("+data.add_time+")</span><br>"+data.content+"</p></div></li>");
三.给大写一个完整的jquery前添加,后追加的案例如下:
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="./jquery-2.2.4.min.js">
</script>
<script type="text/javascript">
$(function(){
//获取按钮并设置点击事件
$("button").click(function(){
//获取输入框里面的值
var value = $("input[name = 'uname']").val();
//
switch ($(this).html()){
case "前添加":
//获取到ul并在其前面添加
//$("ul").prepend("<li>" + value +"</li>");
$("<li>" + value +"</li>").prependTo("ul");
break;
case "后追加":
$("ul").append("<li>" + value +"</li>");
//$("<li>" + value +"</li>").appendTo("ul");
break;
}
});
});
</script>
</head>
<body>
<h2>jquery 前追加和后追加</h2>
<ul>
<li>aaaa</li>
<li>bbbb</li>
<li>cccc</li>
</ul>
名称:<input type="text" name="uname" />
<button>前添加</button>
<button>后追加</button>
</body>
</html>
thinkcmf模板开发教程之<三>thinkcmf5模板中portal:articles标签不解析
博客 • maomao 发表了文章 • 0 个评论 • 4454 次浏览 • 2018-09-17 18:35
在使用thinkcmf5搭建自写主题的时候,有时候用portal:articles标签的时候会提示错误。
未定义数组索引 post_title
这种情况是没有写前置调用代码,在当前模板页面或公共头部模块页面添加代码:
<taglib name="app\portal\taglib\Portal"/>
thinkcmf模板开发教程之<二>动态循环输出轮播图
博客 • maomao 发表了文章 • 0 个评论 • 2303 次浏览 • 2018-09-17 15:39
<slides id="1">
<div class="item <if condition="($key == 0)">active</if>">
<a href="{$vo.url|default=''}" target="_blank" title="{$vo.title|default=''}" >
<img src="{:cmf_get_image_url($vo.image)}" alt="{$vo.title|default=''}" class="img-responsive"></a>
</div>
</slides>