PBOOTCMS 添加全局站点信息自定义字段



因开发需求,网站需要增加全局的自定义字段,方法如下:【已知适用版本V3.2.4】

1:数据库表 ay_site 增加字段 ‘downurl’

2: 修改文件 apps/admin/controller/content/SiteContronller.php

$data = array(
            'title' => post('title'),
            'subtitle' => post('subtitle'),
            'domain' => post('domain'),
            'logo' => post('logo'),
            'keywords' => post('keywords'),
            'description' => post('description'),
            'icp' => post('icp'),
            'theme' => basename(post('theme')) ?: 'default',
            'statistical' => post('statistical'),
            'copyright' => post('copyright'),
	    'downurl' => post('downurl') //新增一行对应代码

        );

3: 修改文件 apps/admin/view/default/content/site.html

//新增对应form的提交内容
<div class="layui-form-item">
                     <label class="layui-form-label">下载URL</label>
                     <div class="layui-input-block">
                     	<input type="text" name="downurl" placeholder="请输入下载URL" class="layui-input" value="{$sites->downurl}" >
                     </div>
                </div>

4:修改解析文件 apps/home/controller/ParseController.php 里面的 public function parserSiteLabel($content) 内容 按照格式新增:

case 'downurl':
                        if (isset($data->downurl)) {
                            $content = str_replace($matches[0][$i], $this->adjustLabelData($params, decode_string($data->downurl)), $content);
                        } else {
                            $content = str_replace($matches[0][$i], '', $content);
                        }

5: 模板调用 {pboot:sitedownurl} 即可