时间:2021-07-21人气:-
<div class="bm bml"> <div class="bm_h cl"> <h2>{lang article_description}</h2> </div> <div class="bm_c"><textarea id="summary" name="summary" cols="80" class="pt" maxlength="120" style="width: 98.7%; height: 51px;">$article[summary]</textarea></div></div>下面添加
<div class="bm bml"> <div class="bm_h cl"> <h2>Tag 标签</h2> </div> <div class="bm_c"><input type="text" id="tags" name="tags" class="px" maxlength="120" size="80" value="$article[tags]" ></div> <div class="bm_h cl">多个Tag 用空格隔开,例如:标签1 标签2 标签3,尾部不需任何符号</div></div>第二步、添加pre_portal_article_title表字段字段名:tags ,类型varchar(255), 默认为空。在后台的站长->数据库->升级 下面的Discuz! 数据库升级,文本框,复制下面SQL:或直接进入PHPMYADMIN数据库操作面板中,进入所在的表 点击SQL 输入如下语句 点击执行:alter table pre_portal_article_title add tags varchar(255)复制代码注意:1、操作前备份数据库,2、不论表前缀是不是默认的,都可以直接用此代码(我的表前缀不是默认的已经成功),如果没有升级成功,那就请用pre_portal_article_title。第三步、修改文章添加,修改,处理,函数/source/include/portalcp/portalcp_article.php查找代码$_POST['pagetitle'] = censor($_POST['pagetitle']);复制代码在此代码下面添加$_POST['tags'] = censor(trim($_POST['tags']));复制代码继续查找
$setarr = array( 'title' => $_POST['title'], 'author' => $_GET['author'], 'from' => $_GET['from'], 'fromurl' => $_GET['fromurl'], 'dateline' => intval($_GET['dateline']), 'url' => $_GET['url'], 'allowcomment' => !empty($_POST['forbidcomment']) ? '0' : '1', 'summary' => $summary, 'catid' => intval($_POST['catid']), 'tag' => article_make_tag($_POST['tag']), 'status' => $article_status, 'highlight' => $style, 'showinnernav' => empty($_POST['showinnernav']) ? '0' : '1', );替换为
$setarr = array( 'title' => $_POST['title'], 'author' => $_GET['author'], 'from' => $_GET['from'], 'fromurl' => $_GET['fromurl'], 'dateline' => intval($_GET['dateline']), 'url' => $_GET['url'], 'allowcomment' => !empty($_POST['forbidcomment']) ? '0' : '1', 'summary' => $summary, 'catid' => intval($_POST['catid']), 'tag' => article_make_tag($_POST['tag']), 'status' => $article_status, 'highlight' => $style, 'showinnernav' => empty($_POST['showinnernav']) ? '0' : '1', 'tags' => $_POST['tags'], );就是在最后一行前加一句以下代码'tags' => $_POST['tags'],复制代码第四步、修改文章显示函数/source/module/portal/portal_view.php找到代码include_once template("diy:portal/view:{$catid}", NULL, $tpldirectory, NULL, $articleprimaltplname);复制代码在此代码上面一行插入代码
$tags=explode(" ",$article["tags"]);foreach($tags as $val) { $htmltags .= "<a href="/search.php?mod=portal&srchtxt=".$val."&searchsubmit=yes" target="_blank">".$val."</a> ";}第五步、修改文章显示模版/template/default/portal/view.htm可以自己选择要放的位置,例如放到内容下面:查找 $content[content]然后在下面加入代码<div><b>Tab标签:</b> $htmltags</div>