很多站长在做网站上的时候一般都喜欢在文章页加一段版权说明,或者文章说明的文字,比如本站文章页下面的那种:
“本文由某某网站发布,转载请注明出处http://xxx.xxx.com/aaa/123.html”
加这段代码的好处在于:一来可以给大家一个版权提示的信息;二来也可以增加一段文章结尾,并带上一个本文的链接,对SEO也会有一点点好处。
那么我们在使用织梦系统的时候该如何实现这个效果呢?在文章模板写上那一段文字是很简单的,主要是如何获取当前文章的URL,默认织梦在文章页是没有这个URL的,我们只有手动来进行添加这个功能了。
第一步:添加函数
打开/include/extend.func.php文件,在其后面添加以下代码:
-
function GetOneDocUrl($aid) //文档URL
-
{
-
global $dsql;
-
include_once(DEDEINC."/channelunit.func.php");
-
$aid = trim(ereg_replace('[^0-9]','',$aid));
-
$chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `info_arctiny` arc left join `info_channeltype` ch on ch.id=arc.channel where arc.id='$aid' ");
-
if(!is_array($chRow)) {
-
return $reArr;
-
}
-
else {
-
if(empty($chRow['maintable'])) $chRow['maintable'] = 'info_archives';
-
}
-
if($chRow['issystem']!=-1)
-
{
-
$nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
-
From `{$chRow['maintable']}` arc left join `info_arctype` tp on tp.id=arc.typeid
-
where arc.id='$aid' ";
-
}
-
else
-
{
-
$nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
-
From `{$chRow['addtable']}` arc left join `info_arctype` tp on tp.id=arc.typeid
-
where arc.aid='$aid' ";
-
}
-
$arcRow = $dsql->GetOne($nquery);
-
$Url = GetFileUrl($aid,$arcRow['typeid'],$arcRow['senddate'],$reArr['title'],$arcRow['ismake'],$arcRow['arcrank'],
-
$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],
-
$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']);
-
return $Url;
-
}
第二步:页面调用
模板文件使用: {dede:field.id function='GetOneDocUrl(@me)'/} 即可调用该文章的网址。
添加上自己的版权文字即可实现下面的效果:
本文由
科宇网络 (西部数码/华夏名网核心代理商) 发表于2013年09月12日,欢迎交流!
转载本文章请注明出处:
http://www.keyu800.net/info/code/dedecms/73.html