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

weeya2年前JTBC教程1023

以新闻模块为例子。

打开/news/common/diplomat/index.php

找到public function list(Request $req, Response $res)函数

修改以下内容:

在代码
$category = intval($req -> get('category') ?? -1);
下面添加一行
$fatherCategory = 0;

在代码
$this -> breadcrumbBuilder -> batchAdd(Navigation::getBreadcrumb($this -> category, $category, '?type=list&category=#category#'));
下面添加一行
$fatherCategory = $this -> category -> getRecordById($category, 'father_id') ?: $category;

在代码
'pagecount' => $model -> pagination -> pageCount,
下面添加一行
'father_category' => $fatherCategory,

这样,在前端代码中可以使用

{$[father_category]}来获取当前分类的上级分类ID

相关文章

J5_04产品新闻列表页

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

J5网站首页增加SEO标题

网站增加首页标题1、/Public/common/language/communal.jtbc文件增加节点    <item>  &nbs...

J5_08留言模块

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

J5_03首页模板

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

J5增加PDF附件下载功能

1、模块管理增加att字段,选择29附件管理器2、模板代码<table class="table table-striped m-0"><tbody><...

J5增加tag标签自定义URL

1、index.php文件detail节点$rsTag = strval($rs -> tag);//增加tag模块管理-添加字段tag,16标签输入框。2、tag/矿山副井井筒装备安装/htt...

发表评论    

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