J5模块首页-列表分类-文章页面自定义TDK

weeya4个月前JTBC教程72

J5模块首页-列表分类-文章页面自定义TDK方法
1、模块添加字段,
后台开发维护》模块管理》右边的设置,在模块设置界面,点击右上角添加新字段按钮
添加3个字段,用来存储自定义的TDK数据
seotitle,01单行文本;seokey,01单行文本;seodesc,02多行文本。
可拖动左边箭头调整显示顺序。
2、程序处理/Public/gallery/common/diplomat/index.php文件
2.1、public function __start(Request $req)节点增加
    $this -> setParam('meta_title', array(Jtbc::take('global.communal.title', 'lng')));//增加开始
    $currentSeotitle = Jtbc::take('index.seotitle', 'lng');
    $currentKeywords = Jtbc::take('index.keywords', 'lng');
    $currentDescription = Jtbc::take('index.description', 'lng');
    if (!Validation::isEmpty($currentSeotitle))
    {
      $this -> addParam('meta_title', $currentSeotitle);
    }
    if (!Validation::isEmpty($currentKeywords))
    {
      $this -> setParam('meta_keywords', $currentKeywords);
    }
    if (!Validation::isEmpty($currentDescription))
    {
      $this -> setParam('meta_description', $currentDescription);
    }//增加结束
2.2、节点最后一行屏蔽掉
    //$this -> setParam('category', $this -> category);
2.3public function list(Request $req, Response $res)节点
找到$categorys = $this -> category -> getFatherGroupById($category, true);在下面增加以下代码
      $categoryRs = $this -> category -> getRecordById($category);//增加
      $categoryRsSeotitle = strval($categoryRs -> seotitle);//增加
      $categoryRsKeywords = strval($categoryRs -> keywords);//增加
      $categoryRsIntro = strval($categoryRs -> intro);//增加
2.4找到$this -> addParam('meta_title', $item['title']);}在下面增加以下代码
      $this -> setParam('meta_title', array(Jtbc::take('global.communal.title', 'lng')));//增加开始
      if (!Validation::isEmpty($categoryRsSeotitle))
      {
        $this -> addParam('meta_title', $categoryRsSeotitle);
      }
      else $this -> addParam('meta_title', $item['title']);
      if (!Validation::isEmpty($categoryRsKeywords))
      {
        $this -> setParam('meta_keywords', $categoryRsKeywords);
      }
      if (!Validation::isEmpty($categoryRsIntro))
      {
        $this -> setParam('meta_description', $categoryRsIntro);
      }//增加结束
2.5修改函数public function detail(Request $req, Response $res)节点代码
找到$rsTitle = strval($rs -> title);下面添加
      $rsSummary = strval($rs -> summary);//增加
      $rsSeoTitle = strval($rs -> seotitle);//增加
      $rsSeoKey = strval($rs -> seokey);//增加
      $rsSeoDesc = strval($rs -> seodesc);//增加
修改代码$this -> addParam('meta_title', $rsTitle);为
      $this -> setParam('meta_title', array(Jtbc::take('global.communal.title', 'lng')));//增加
      if (!empty($rsSeoTitle)) $this -> addParam('meta_title', $rsSeoTitle);//增加
      else $this -> addParam('meta_title', $rsTitle);//增加
      if (!empty($rsSeoKey)) $this -> setParam('meta_keywords', $rsSeoKey);//增加
      if (!empty($rsSeoDesc)) $this -> setParam('meta_description', $rsSeoDesc);//增加
      else if (!empty($rsSummary)) $this -> setParam('meta_description', $rsSummary);//增加
说明:summary字段为新闻模块中的描述字段,如果修改的模块没有这个字段,请自行去除相关代码即可。
3、/Public/gallery/common/language/index.jtbc文件增加节点
    <item>
      <name><![CDATA[seotitle]]></name>
      <zh-cn><![CDATA[多肉植物SEO标题]]></zh-cn>
    </item>
    <item>
      <name><![CDATA[keywords]]></name>
      <zh-cn><![CDATA[多肉植物关键词]]></zh-cn>
    </item>
    <item>
      <name><![CDATA[description]]></name>
      <zh-cn><![CDATA[多肉植物描述信息]]></zh-cn>
    </item>
4、打开分类关键描述/Public/gallery/common/category.jtbc
    <item>
      <name><![CDATA[has_seotitle]]></name>
      <zh-cn><![CDATA[true]]></zh-cn>
    </item>
    <item>
      <name><![CDATA[has_keywords]]></name>
      <zh-cn><![CDATA[true]]></zh-cn>
    </item>
    <item>
      <name><![CDATA[has_intro]]></name>
      <zh-cn><![CDATA[true]]></zh-cn>
    </item>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·
5、/Public/universal/category/common/language/config.jtbc文件增加节点
    <item>
      <name><![CDATA[seotitle]]></name>
      <zh-cn><![CDATA[分类SEO标题]]></zh-cn>
    </item>
6、分类数据库增加字段seotitle,类型VARCHAR,长度200,默认NULL,排序规则utf8mb4_general_ci,注释{"required":false}
7、/Public/universal/category/common/template/manage.jtbc文件
add增加
<li if="${$property.has_seotitle}"><input is="jtbc-input" type="text" name="seotitle" role="field" placeholder="{$=$take('config.seotitle', 'lng')}" /></li>
edit增加
<li if="${$property.has_seotitle}"><input is="jtbc-input" type="text" name="seotitle" role="field" placeholder="{$=$take('config.seotitle', 'lng')}" value="${$data.seotitle}" /></li>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·
其中5、6、7步骤一个网站只需要修改一次。其他步骤每个模块重复一次操作。

相关文章

J5_06关于我们联系我们内容页

1、头尾模板调用代码{$=$take('global.communal.header')}{$=$take('global.communal.footer')}{$ti...

J5列表中获取当前分类的父分类ID

以新闻模块为例子。打开/news/common/diplomat/index.php找到public function list(Request $req, Response $res)函数修改以下内...

J5_08留言模块

联系我们模块放留言板1、/Public/contactus/common/diplomat.index.php文件      $renderer =...

J5_02公共模板

头部尾部    <TITLE>{$=$htmlEncode(implode(' - ', array_reverse($meta_title)...

J5_05产品新闻详情页

1、头尾模板调用代码{$=$take('global.communal.header')}{$=$take('global.communal.footer')}{$ti...

J5_09搜索

    需要在可以被搜索的模块目录中手动添加common/search.jtbc引导文件来激活搜索功能    需要手动构建关键字输入框并通过...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。