• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > DedeCMS教程 > DedeCMS安装使用 >

如何将dedecms的标题直接链接到外部

来源: www.dedecms8.com 编辑:织梦吧 时间:2010-08-23点击:

真正的【将标题直接链接到外部链接】

功能:
将标题直接链接到外部链接,后台文章录入:直接添加转向网址即可,无须其他选择,不转向请留空。
网址为动态转向,记录点击数,外连和动态文章一样可以设置收费等。
改法:

第一步
假设dede_为表前缀,则在dede_archives 添加一字段
字段名:redirecturl


打开:view.php
找到:
CODE: $arc->Display();
$arc->Close(); [Copy to clipboard]
前面加入:
CODE: $url = new Archives($aid);
$redirecturl = $url->ArcInfos['redirecturl'];
if ($redirecturl != "") {
$dsql = new DedeSql(false);
$dsql->SetQuery("Update dede_archives set click=click 1 where ID='$aid'");
$dsql->ExecuteNoneQuery();
header("Location:$redirecturl");
exit();
}
$url->Close(); [Copy to clipboard]
打开:article_add.php
找到
CODE: <table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80">阅读权限:</td>
<td width="224"> <select name="arcrank" id="arcrank" style="width:150">
<?
$urank = $cuserLogin->getUserRank();
$dsql = new DedeSql(false);
$dsql->SetQuery("Select * from dede_arcrank where adminrank<='$urank'");
$dsql->Execute();
while($row = $dsql->GetObject())
{
echo " <option value='".$row->rank."'>".$row->membername."</option>
";
}
$dsql->Close();
?>
</select> </td>
<td width="63">发布选项:</td>
<td><input name="ishtml" type="radio" class="np" value="1" checked>
生成HTML
<input type="radio" name="ishtml" class="np" value="0">
仅动态浏览</td>
</tr>
</table> [Copy to clipboard]
后面加入:
CODE: <table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80">转向网址:</td>
<td width="520"><input name="redirecturl" type="text" id="redirecturl" style="width:250px"></td>
</tr> </table> [Copy to clipboard]
打开:article_edit.php
找到:
CODE: <table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80">阅读权限:</td>
<td width="224">
<select name="arcrank" id="arcrank" style="width:150">
<option value='<?=$arcRow["arcrank"]?>'><?=$arcRow["rankname"]?></option>
<?
$urank = $cuserLogin->getUserRank();
$dsql = new DedeSql(false);
$dsql->SetQuery("Select * from dede_arcrank where adminrank<='$urank'");
$dsql->Execute();
while($row = $dsql->GetObject())
{
echo " <option value='".$row->rank."'>".$row->membername."</option>
";
}
$dsql->Close();
?>
</select> </td>
<td width="63">发布选项:</td>
<td>
<input name="ishtml" type="radio" class="np" value="1"<?if($arcRow["ismake"]!=-1) echo " checked";?>>
生成HTML
<input type="radio" name="ishtml" class="np" value="0"<?if($arcRow["ismake"]==-1) echo " checked";?>>
仅动态浏览
</td>
</tr>
</table> [Copy to clipboard]
后面加入:
CODE: <table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80">转向网址:</td>
<td width="520"><input name="redirecturl" type="text" id="redirecturl" style="width:250px" value="<?=$arcRow["redirecturl"]?>"></td>
</tr>
</table> [Copy to clipboard]

打开:action_archives_save.php
找到
CODE: if($ishtml==0) $ismake = -1; [Copy to clipboard]
改为
CODE: if($redirecturl!="") $ishtml = 0;
if($ishtml==0) $ismake = -1; [Copy to clipboard]
适当地方加入:
CODE: $redirecturl = cn_substr($redirecturl,250); [Copy to clipboard]
查询语句:对照加入redirecturl
CODE:
//加入数据库的SQL语句
//----------------------------------
$inQuery = "INSERT INTO dede_archives(
typeid,typeid2,sortrank,iscommend,ismake,channel,
arcrank,click,money,title,color,writer,source,litpic, pubdate,senddate,adminID,memberID,description,keywords,redirecturl)
VALUES ('$typeid','$typeid2','$sortrank','$iscommend','$ismake','$channelid',
'$arcrank','0','$money','$title','$color','$writer','$source','$litpic',
'$pubdate','$senddate','$adminID','0','$description','$keywords','$redirecturl');"; [Copy to clipboard]

打开:action_archives_edit_save.php
找到
CODE: if($ishtml==0) $ismake = -1; [Copy to clipboard]
改为
CODE: if($redirecturl!="") $ishtml = 0;
if($ishtml==0) $ismake = -1; [Copy to clipboard]
适当地方加入:
CODE: $redirecturl = cn_substr($redirecturl,250); [Copy to clipboard]
查询语句:
CODE: //更新数据库的SQL语句
//----------------------------------
$inQuery = "
update dede_archives set
typeid='$typeid',
typeid2='$typeid2',
sortrank='$sortrank',
iscommend='$iscommend',
ismake='$ismake',
arcrank='$arcrank',
money='$money',
title='$title',
color='$color',
writer='$writer',
source='$source',
litpic='$litpic',
pubdate='$pubdate',
description='$description',
keywords='$keywords',
redirecturl='$redirecturl'
where ID='$ID'; "; [Copy to clipboard]

CODE: [/code]

[code] [Copy to clipboard]

CODE: [/code]

[code]
 

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1170734538@qq.com ,  QQ