SuperAPI AI 工具集

basercms5-theme-development

前端与建站

查看项目

更新于 10-15 17:24

技能介绍

本技能面向 baserCMS 5系(CakePHP 5 基础)主题的新规开发与改修。5系主题以插件形式存在,放在 plugins/<ThemeName>/,由 templates/、webroot/ 以及少量前台显示用 Helper(src/View/Helper/)构成。config.php 需返回含 'type' => 'Theme' 的数组。

主要结构与能力:layout 用 $this->fetch('content') 输出正文,head 内用 BcBaser 的 charset()/title()/css()/js()/scripts();固定页面模板用 echo $page->contents 输出管理端编辑内容;内容模板按“功能插件名/模板名/动作名”放置,缺失时回退到核心模板。

用法要点:模板中 $this 为 View,不要调用 $this->getView();登录用户用 BcUtil::loginUser() 获取并判定 false;当前内容与站点从请求属性 currentContent/currentSite 取,可能为 null。Helper 通过 loadHelper 加载,不要 new。URL 用 BcBaser->getUrl() 生成,避免硬编码。css()/js() 第二参数为 inline,属性放第三参数。上传图片用 uploadImage('<field>', $entity, $options),并显式指定 table。Widget element 放在 templates/element/widget/。邮件表单模板放 templates/Mail/<模板名>/,file 型字段需先调用 setTableToUpload('BcMail.MailMessages')。博客模板放 templates/Blog/<模板名>/,日期字段为 posted。

限制:主题若需 Controller/Table 等内部代码应参考插件开发技能;4系迁移另见升级技能。技能资料未提供具体收费、价格与效果信息。