欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」PbootCms扩展控制器源码分享

作者 : 自学哈 本文共2502个字,预计阅读时间需要7分钟 2023-03-7 共119人阅读
也想出现在这里? 联系我们

准备工作

PbootCms自V2.0.6开始新增了扩展控制器功能,的优点是升级不被覆盖,再也不懂担心自己二开的内容被升级覆盖啦。

每个人都有自己习惯的一些代码风格、方式,以下是我个人对PbootCms的一些扩展集合,会不定期更新一些内容。

各位只需要将以下代码复制到:/apps/home/controller/ExtLabelController.php

这个路径下就好啦。

当然还是要做一点点修改,如下:

文件路径:/apps/home/controller/ParserController.php大约在50行的如下代码:

//解析个人扩展标签,升级不覆盖

if(file_exists(APP_PATH.’/home/controller/ExtLabelController.php’)){

if(class_exists(‘apphomecontrollerExtLabelController’)){

$extlabel=new ExtLabelController();

$content=$extlabel->run($content);

}

}

移动到该方法的最下面,也就是在该方法的:

return$content;

之前,这个代码之前,最终方法如下:

//解析全局后置公共标签

public function parserAfter($content)

{

//默认页面信息替换

$content=str_replace(‘{pboot:pagetitle}’,'{pboot:sitetitle}-{pboot:sitesubtitle}’,$content);

$content=str_replace(‘{pboot:pagekeywords}’,'{pboot:sitekeywords}’,$content);

$content=str_replace(‘{pboot:pagedescription}’,'{pboot:sitedescription}’,$content);

$content=$this->parserSingleLabel($content);//单标签解析

$content=$this->parserSiteLabel($content);//站点标签

$content=$this->parserCompanyLabel($content);//公司标签

$content=$this->parserUserLabel($content);//自定义标签

$content=$this->parserNavLabel($content);//分类列表

$content=$this->parserSelectAllLabel($content);//CMS筛选全部标签解析

$content=$this->parserSelectLabel($content);//CMS筛选标签解析

$content=$this->parserSpecifySortLabel($content);//指定分类

$content=$this->parserListLabel($content);//指定列表

$content=$this->parserSpecifyContentLabel($content);//指定内容

$content=$this->parserContentPicsLabel($content);//内容多图

$content=$this->parserContentCheckboxLabel($content);//内容多选调取

$content=$this->parserContentTagsLabel($content);//内容tags调取

$content=$this->parserSlideLabel($content);//幻灯片

$content=$this->parserLinkLabel($content);//友情链接

$content=$this->parserMessageLabel($content);//留言板

$content=$this->parserFormLabel($content);//自定义表单

$content=$this->parserSubmitFormLabel($content);//自定义表单提交

$content=$this->parserQrcodeLabel($content);//二维码生成

$content=$this->parserPageLabel($content);//CMS分页标签解析(需置后)

$content=$this->parserLoopLabel($content);//LOOP语句(需置后)

$content=$this->parserIfLabel($content);//IF语句(需置最后)

$content=$this->restorePreLabel($content);//还原不需要解析的内容

$content=$this->parserReplaceKeyword($content);//页面关键词替换

//解析个人扩展标签,升级不覆盖

if(file_exists(APP_PATH.’/home/controller/ExtLabelController.php’)){

if(class_exists(‘apphomecontrollerExtLabelController’)){

$extlabel=new ExtLabelController();

$content=$extlabel->run($content);

}

}

return$content;

}

为什么要这么做?因为实际开发过程中,会需要对后台输出的字段进行二次处理,那么如果扩展控制器放在前面处理,就会发生无法获取后台字段的情况。

那么我们只要将扩展控制器放到最后来执行,就可以啦。

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」PbootCms扩展控制器源码分享
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号