pbootcms使用技巧

pbootcms是与aspcms一家公司开发的企业网站系统,非常完美的企业网站系统,功能齐全,方便灵活,支持sqlite/mysql数据库

模板中支持简单的php语句

 {php}echo 111+222;{/php}

数据库快速操作类 类似THINKPHP框架的方式 比较容易上手

引入命名空间
use corebasicModel;
use corebasicDb;

$a = Db::table('ay_content')->where('id=1')->find();
var_dump($a); 
$model = new Model();
$r = $model->table('ay_content')->where('id=1')->find();
var_dump($r);

以上两种是等价的,第一种Db通过__callstatic静态魔术方法来调用Model类的方法

pbootcms导入其它数据库的信息

public function importold()
{
    exit('已經導入新聞');
    set_time_limit(0);
    $data = json_decode('{"acode":"cn","scode":"16","subscode":"","title":"\u6807\u9898","titlecolor":"#333333","subtitle":"","filename":"","author":"admin","source":"\u672c\u7ad9","outlink":"","date":"2018-12-30 10:45:46","ico":"\/static\/upload\/image\/20181230\/1546137994102175.png","pics":"\/static\/upload\/image\/20181230\/1546138005227320.png,\/static\/upload\/image\/20181230\/1546138006814526.png","content":"

\u5185\u5bb9<\/p>","enclosure":"","keywords":"","description":"\u5185\u5bb9","sorting":255,"status":"1","istop":0,"isrecommend":0,"isheadline":0,"visits":0,"likes":0,"oppose":0,"create_user":"admin","update_user":"admin"}',true); //var_dump($data);die(); //对应关系数组 文章 产品 单页 $relation = array( 1 => 16, 3 => 12, 6 => 38, 8 => 35, 10 => 18, 13 => 25, 15 => 31, 18 => 13, 20 => 14, 31 => 22, 33 => 27, 34 => 33 ); $i = 0; //php访问mdb 数据库 //成功导入数据1611条 $connstr = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=#Database#.mdb"; $connid = @odbc_connect($connstr,"","",SQL_CUR_USE_ODBC ) or die ("数据库连接错误!"); $sql = "select * from jtbc_articles"; $exec = odbc_exec($connid,$sql); while($row = odbc_fetch_array($exec)) { //重置这些内容 以免下一个 $data['ico'] = ''; $data['pics'] = ''; if(isset($relation[$row['a_class']]) && $row['a_id'] != 540) { //有相应的栏目对应关系的话 $data['scode'] = $relation[$row['a_class']]; $data['title'] = escape_string(iconv('gb2312', 'utf-8', $row['a_topic'])); $data['content'] = iconv('gb2312', 'utf-8', $row['a_content']); $data['content'] = escape_string(str_replace('{$->>repath}articles/common/upload/', '/static/upload/', $data['content'])); $data['description'] = mb_substr(strip_tags($data['content']), 0, 150, 'utf-8'); $data['date'] = $row['a_time']; $data['visits'] = $row['a_count']; if ($row['a_content_images'] != '') { if (strpos($row['a_content_images'], '|') !== false) { $data['pics'] = str_replace('|', ',', $row['a_content_images']); $data['pics'] = str_replace('common/upload/', '/static/upload/', $data['pics']); $data['ico'] = explode(',', $data['pics'])[0]; } else { $data['ico'] = $row['a_content_images']; } } //var_dump($data); //exit(); if (! ! $id = $this->model->addContent($data)) { $i++; } } } echo "成功导入数据" . $i . '条'; }

先断点获取到输入文章时的数组,每条导入数据只需要赋值需要变更的部分,注意每次重置数据项为空

碰到的大坑
php odbc连接 查询显示不完整问题
在php.ini里找到[ODBC] 下面有odbc.defaultlrl = 4096 你改正你想要设置 的大小就ok

有子分类调用子分类 没有子分类显示同级分类

修改标签解析控制器方法 ParserController.php中的 paseSortLabel,添加case分支

case 'soncount':
                        $content = str_replace($matches[0][$i], count($this->model->getSubScodes($sort->scode)), $content);
                        break;

将appshomemodelParserModel.php中的getSubScodes方法改为public

 public function getSubScodes($scode)

模板标签写法


                        {pboot:if({sort:soncount} == 1)}
                        
    {pboot:nav num=100 parent={sort:pcode}}
  • [nav:name]
  • {/pboot:nav}
{else}
    {pboot:nav num=100 parent={sort:scode}}
  • [nav:name]
  • {/pboot:nav}
{/pboot:if}

自带分页条及样式

{page:bar}
/* 分页样式 */
.paging { margin-top: 32px; font-size: 14px; }
.paging > span { margin: auto 16px; }
.paging .page-numbar { margin: auto 0; }
.paging .page-numbar .page-num,
.paging .page-index,
.paging .page-pre,
.paging .page-next,
.paging .page-last { display: inline-block; margin: auto 4px; padding: 2px 12px; border: 1px solid #EEE; border-radius: 2px; }
.paging .page-numbar .page-num-current,
.paging .page-numbar .page-num:hover { border-color: #8667F7; color: #8667F7; }

你可能感兴趣的:(php,cms)