J5增加tag标签自定义URL
1、index.php文件detail节点
$rsTag = strval($rs -> tag);//增加tag
模块管理-添加字段tag,16标签输入框。
2、tag/矿山副井井筒装备安装/
http://www.tkrockdrill.com/tag/%E7%9F%BF%E5%B1%B1%E5%89%AF%E4%BA%95%E4%BA%95%E7%AD%92%E8%A3%85%E5%A4%87%E5%AE%89%E8%A3%85/product/
自定义URL
$slug = strval($req -> get('slug'));
manage.php文件
add节点加上
$schemaGenerator -> extra -> tag = ['api' => 'universal/tag/manageApi?type=list&genre=' . urlencode($genre)];
$schemaGenerator -> tips -> slug = Jtbc::take('manage.text-tips-field-slug', 'lng');
edit节点加上
搜索$data = $rs -> toArray();下面加以下代码
$genre = $this -> getParam('genre');
$lang = $this -> guard -> role -> getLang();
$category = new Category($genre, $lang);
搜索if (!$this -> guard -> role -> checkPermission('publish'))上面加以下代码
$schemaGenerator -> extra -> tag = ['api' => 'universal/tag/manageApi?type=list&genre=' . urlencode($genre)];
$schemaGenerator -> tips -> slug = Jtbc::take('manage.text-tips-field-slug', 'lng');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~···
新闻模块增加tag标签文章列表
找到public function list(Request $req, Response $res)节点
1、搜索$page = intval($req -> get('page'));在上面增加以下代码
$tag = strval($req -> get('tag'));//tag增加
$keyword = strval($req -> get('keyword'));//tag增加
2、搜索$model -> orderBy('time', 'desc');在上面增加以下代码
if (!Validation::isEmpty($tag))//tag增加开始
{
$model -> where -> tag -> like('%"' . $tag . '"%');
}
if (!Validation::isEmpty($keyword))
{
$model -> where(function($where) use ($keyword){
$where -> title -> like('%' . $keyword . '%');
$where -> summary -> or -> like('%' . $keyword . '%');
});
}//tag增加结束
tag前端链接/blog/?type=list&tag=网站设计
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~···
文章所属tag
{$=$render('global.render.blog-tags', $convertToOption($jsonDecode(#tag) ?? []))}
节点 [ blog-tags ]代码
<a href="{$=$getActualRoute('blog')}/?type=list&tag={$=urlencode(#text)}">{$text}</a>
右侧调用tag列表
{$=$render('global.render.sidebar-tags', $fetch(['genre' => 'universal/tag', 'where' => ['genre' => 'blog'], 'orderBy' => [['associated_count', 'desc']], 'limit' => 50]))}
节点 [ sidebar-tags ]代码
<section>
<h3>{$=$take('global.communal.sidebar-tags', 'lng')}</h3>
<div class="tags">{@}<a href="{$=$getActualRoute('blog')}/?type=list&tag={$=urlencode(#tag)}">{$tag}</a>{@}</div>
</section>