dedecms 5.3将跳转网址改成直接链接的方法

作者:ly56651283

要点,就是想办法将redirecturl 字段调出来,然后在跳转的时候加个判断让它以直接链接形式存在。。

程序升级至最新,直接用以下的代码替换源文件里相应位置的代码。

1.列表页的修改方法如下:
include\arc.listview.class.php : 591行(修改SQL语句)
//如果不用默认的sortrank或id排序,使用联合查询(数据量大时非常缓慢)
if(ereg(‘hot|click|lastpost’,$orderby))
{
$query = “Select arc.*,`$addtable`.redirecturl,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
$addField
from `#@__archives` arc
left join `#@__arctype` tp on arc.typeid=tp.id
$addJoin
where {$this->addSql} $ordersql limit $limitstart,$row”;
}

include\arc.listview.class.php : 618行(修改SQL语句)
$query = “Select arc.*,`$addtable`.redirecturl,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,
tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
$addField
from `#@__archives` arc left join `#@__arctype` tp on arc.typeid=tp.id
$addJoin
where arc.id in($idstr) $ordersql “;

include\arc.listview.class.php : 656行(在“$row[‘filename’] = $row[‘arcurl’] = GetFileUrl(…”前加句判断)
if ($row[‘redirecturl’]) $row[‘filename’] = $row[‘arcurl’]  = $row[‘redirecturl’] ; else//跳转链接转直接链接

2.首页的修改方法如下:
include\inc\arclist.lib.php :  183行(修改SQL语句)
//12.26修改跳转
$addtable = [url=mailto:]’#@__addonarticle‘[/url];
$query = “Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,$addtable.redirecturl
from `$maintable` arc
inner join [url=mailto:`#@__arctype]`#@__arctype[/url]` tp on tp.id=arc.typeid
left outer join $addtable   on  arc.id = $addtable.aid
$orwhere $ordersql $limitsql”;

include\inc\arclist.lib.php :  227行(在“$row[‘filename’] = $row[‘arcurl’] = GetFileUrl(…”前加句判断判断)
if ($row[‘redirecturl’]) $row[‘filename’] = $row[‘arcurl’]  = $row[‘redirecturl’] ; else//跳转链接转直接链接

注意一点,从这往上还有几处要修改一下,因为该语句中typeid比较含糊不清,要改成arc.typeid,否则发布文章啥的有问题,直接替换如下代码:
if(!empty($typeid))
{
//指定了多个栏目时,不再获取子类的id
if(ereg(‘,’,$typeid)) $orwheres[] = ” arc.typeid in ($typeid) “;
else
{
//处理交叉栏目
$CrossID = ”;
if((isset($envs[‘cross’]) || $ctag->GetAtt(‘cross’)==’1′ ) && $ctag->GetAtt(‘nocross’)!=’1′)
{
$arr = $dsql->GetOne(“Select `id`,`topid`,`cross`,`crossid`,`ispart`,`typename` From [url=mailto:`#@__arctype]`#@__arctype[/url]` where id=’$typeid’ “);
if($arr[‘cross’]==0 || ($arr[‘cross’]==2 && trim($arr[‘crossid’]==”)))
$orwheres[] = ‘ arc.typeid in (‘.GetSonIds($typeid).’)’;
else
{
$selquery = ”;
if($arr[‘cross’]==1) {
$selquery = “Select id,topid From [url=mailto:`#@__arctype]`#@__arctype[/url]` where typename like ‘{$arr[‘typename’]}’ And id<>'{$typeid}’ And topid<>'{$typeid}’  “;
}
else {
$arr[‘crossid’] = ereg_replace(‘[^0-9,]’,”,trim($arr[‘crossid’]));
if($arr[‘crossid’]!=”) $selquery = “Select id,topid From [url=mailto:`#@__arctype]`#@__arctype[/url]` where id in(‘{$arr[‘crossid’]}’) And id<>'{$typeid}’ And topid<>'{$typeid}’  “;
}
if($selquery!=”)
{
$dsql->SetQuery($selquery);
$dsql->Execute();
while($arr = $dsql->GetArray()) {
$CrossID .= ($CrossID==” ? $arr[‘id’] : ‘,’.$arr[‘id’]);
}
}
}
}
if($CrossID==”) $orwheres[] = ‘ arc.typeid in (‘.GetSonIds($typeid).’)’;
else $orwheres[] = ‘ arc.typeid in (‘.GetSonIds($typeid).’,’.$CrossID.’)’;
}
}

附:升级后,将丢失的跳转网址找回来的办法
http://bbs.dedecms.com/read.php?tid=114594

订阅评论
提醒
guest的头像

0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x