discuz viewthread.php,修改discuz论坛的标题header和footer
1、關(guān)于去掉DZ論壇標(biāo)題處的Powered by Discuz!,去掉他的原因是為了使標(biāo)題更加簡潔明了,還有就是不被搜索到導(dǎo)致SPAM:具體的修改方法:打開/templates/default/header.htm,在第五行中直接刪除:- Powered by Discuz!就可。
2、如果針對DZ底部的版權(quán)信息進(jìn)行修改,建議不要進(jìn)行大的修改,那是版權(quán)問題,在這里:風(fēng)格 模板里 /templates/default/footer.html 注意對應(yīng)自己正在使用的模板,第47行處開始。
3、去掉多余的或修改Meta部分“”同樣在header.htm內(nèi)。將 改為
/>,
Meta區(qū)中這兩個可以留1個即可,是為了保護(hù)作者的版權(quán):
打開archiver/include/header.inc.php,將前面對應(yīng)的改為:
=$_DCACHE['settings']['seotitle']?> =$navtitle?> =$_DCACHE['settings']['bbname']?> -?? Archiver將Kewords中的Discuz!,Board,Comsenz,forums,bulletin board,去掉,將meta name="description"后邊的 - Discuz! Archiver也可去掉,同樣跟上邊說的一樣,將
其中之一去掉1個。
把關(guān)鍵字放大:修改 forum.inc.php,index.inc.php,thread.inc.php
在這些文件的最后加入
>=$_DCACHE['settings']['seokeywords']?>
論壇信息分類優(yōu)化:
打開viewthread.php
查找:
$navigation = "? $forum[name] ? $thread[subject]";
$navtitle = $thread['subject'].' - '.strip_tags($forum['name']);
if($forum['type'] == 'sub') {
$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$fup = $db->fetch_array($query);
$navigation = "? $fup[name] $navigation";
$navtitle = $navtitle.' - '.strip_tags($fup['name']);
}
$navtitle .= ' - ';
替換成:
if($lastvisit < $thread['lastpost'] && (!isset($_DCOOKIE['fid'.$fid]) || $thread['lastpost'] > $_DCOOKIE['fid'.$fid])) {
dsetcookie('fid'.$fid, $thread['lastpost'], 3600);
}
$navigation = "? $forum[name] ? $thread[subject]";
if($thread['typeid'] && isset($forum['threadtypes']['types'][$thread['typeid']])) {
$navtitle = '('.$forum['threadtypes']['types'][$thread['typeid']].')'.$thread['subject'].' - '.strip_tags($forum['name']);
}else{
$navtitle = $thread['subject'].' - '.strip_tags($forum['name']);
}
if($forum['type'] == 'sub') {
$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$fup = $db->fetch_array($query);
$navigation = "? $fup[name] $navigation";
$navtitle = $navtitle.' - '.strip_tags($fup['name']);
}
$navtitle .= ' - ';
用googleSitemap 和 雅虎url工具優(yōu)化論壇,完成!
在misc.php中找到$threadurl = "{$boardurl}viewthread.php?tid=$tid";
(奇怪的是6.0的新版本中是$threadurl = "{$boardurl}viewthread.php?tid=$tid$fromuid"; 所以我在這里沒有改。)改為
$threadurl = "{$boardurl}viewthread.php?tid=$tid&fromuid=$discuz_uid";
在推薦朋友功能中增加推薦人的標(biāo)記。這樣的推薦能給推薦人帶來金幣收入。
高級優(yōu)化?前提:1.discuz! 5.0/5.5 已啟用偽靜態(tài)功能,只啟用普通頁面靜態(tài)化就可以了;2.不要啟用Archiver功能?;3.后臺的keywords和description設(shè)置只是針對首頁的<>(如果您沒做列表頁和內(nèi)容頁的meta修改則也應(yīng)用到它們);4.后臺首頁文件名為/(當(dāng)然您也可以設(shè)置自己特定的),然后開始優(yōu)化:
一、meta的優(yōu)化
discuz的后臺可以對meta信息進(jìn)行設(shè)置,甚至可以添加自己的頭部信息,但它的設(shè)置都是針對于所有頁面的,全部頁面都擁有相同的keywords和description是SEO所不贊成的。
方案一:刪除meta
修改頁頭模板文件 templates/default/header.htm:將meta的keywords和description標(biāo)簽刪除。
這兩個標(biāo)簽作用很小了,而且還有discuz自帶的一些無用信息,用得不好反而會有壞作用,因此寧缺勿濫。
方案二:定制meta
本部分實(shí)現(xiàn)了將內(nèi)容頁keywords設(shè)為帖子標(biāo)題,description為內(nèi)容前100字;也實(shí)現(xiàn)了主頁與各版列表頁meta的單獨(dú)設(shè)置(不同版的不同,同一版各列表頁相同)。
1.修改頁頭模板文件 templates\default\header.htm:將meta的keywords和description標(biāo)簽改為如下形式:
這里的$seokeywords、$seodescription就是后臺設(shè)置的那個值,下面說怎么定制這個值;{$metakeywords}是奇虎的關(guān)鍵字,留下以后處理
2.內(nèi)容頁(viewthread)設(shè)置keywords為帖子標(biāo)題,description為內(nèi)容前100字
2.1修改 viewthread.php 文件:
在 include template('viewthread'); (更新:dz5.5為iinclude template($iscircle ? 'supesite_viewthread' : 'viewthread'); ) 語句的上面加入一行:
require_once DISCUZ_ROOT.'./include/bmt.thread.inc.php';
2.2創(chuàng)建 include/bmt.thread.inc.php 文件,內(nèi)容為:
if(!defined('IN_DISCUZ')) { exit('Access Denied'); }
$seokeywords = strip_tags($thread['subject']); //關(guān)鍵字設(shè)為帖子的標(biāo)題
//(已更新: nethome 提出問題,當(dāng)啟用主題分類并允許按類別瀏覽時,原來代碼會有問題。所以加了標(biāo)簽過濾,本來在viewthread.php中改更好,為以后升級方便,還是放在這里吧,subject很短,不會影響效率)
$seodescription = current( $postlist );//description取文章內(nèi)容的前100字
$seodescription = mb_substr( $seodescription['message'],0,100,"gb2312" );
$seodescription = htmlspecialchars( strip_tags($seodescription) );
?>
*此處數(shù)字和個別函數(shù)適用于GBK版本,utf 8 的可能有個別不一樣,請大家繼續(xù)尋找相關(guān)更適合自己版本的優(yōu)化內(nèi)容。
總結(jié)
以上是生活随笔為你收集整理的discuz viewthread.php,修改discuz论坛的标题header和footer的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 光耦驱动单向可控硅_华越国际一文带路:可
- 下一篇: 全键合金!魅族携手IQUNIX推出新款机