dedecms给分类栏目增加不同的友情链接
2012-04-02 10:16 来源:www.chinab4c.com 作者:dedecms专家
dedecms给分类栏目增加不同的友情链接,这个是每个人都梦想的一件事情,如果能让dedecms不同栏目支持不同的友情链接,这将为我们的网站外链处理提供很大的便利。
1:修改dedecms数据库结构。alter table dede_flink add column typeid1 int(1) default 0;
2:friendlink_add.php
require_once(DEDEADMIN."/inc/inc_catalog_options.php");
$query = "INSERT INTO `dede_flink`(sortrank,url,webname,logo,msg,email,typeid,dtime,ischeck,typeid1)
VALUES('$sortrank','$url','$webname','$imgurl','$msg','$email','$typeid','$dtime','$ischeck','$typeid1'); ";
3:friendlink_edit.php
require_once(DEDEADMIN."/inc/inc_catalog_options.php");
$query = "UPDATE `dede_flink` SET sortrank='$sortrank',url='$url',webname='$webname',logo='$logo',msg='$msg',
email='$email',typeid='$typeid',typeid1='$typeid1',ischeck='$ischeck' WHERE id='$id' ";
4:friendlink_edit.htm增加以下代码
<?php
$typeOptions = GetOptionList($myLink['typeid1'],$cuserLogin->getUserChannel());
echo "<select name='typeid1' id='typeid1' style='width:240px'>\r\n";
echo "<option value='0'>请选择栏目...</option>\r\n";
echo $typeOptions;
echo "</select>";
?>
5:增加自定义标签
function lib_aflink(&$ctag,&$refObj)
{
global $dsql,$cfg_soft_lang;
$attlist="type|textall,row|24,titlelen|24,linktype|1,typeid|0|typeid1|0";
FillAttsDefault($ctag->CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$totalrow = $row;
$revalue = '';
if(trim($ctag->GetInnerText())=='') $innertext = "<li>[field:link /]</li>";
else $innertext = $ctag->GetInnerText();
$equery = "SELECT * FROM dede_flink where typeid1= ".$refObj->Fields['id']." order by sortrank asc limit 0,10";
$dsql->SetQuery($equery);
$dsql->Execute();
while($dbrow=$dsql->GetObject())
{
if($type=='text'||$type=='textall')
{
$link = "<a href='".$dbrow->url."' target='_blank'>".cn_substr($dbrow->webname,$titlelen)."</a> ";
}
else if($type=='image')
{
$link = "<a href='".$dbrow->url."' target='_blank'><img src='".$dbrow->logo."' width='88' height='31' border='0'></a> ";
}
else
{
if($dbrow->logo=='')
{
$link = "<a href='".$dbrow->url."' target='_blank'>".cn_substr($dbrow->webname,$titlelen)."</a> ";
}
else
{
$link = "<a href='".$dbrow->url."' target='_blank'><img src='".$dbrow->logo."' width='88' height='31' border='0'></a> ";
}
}
$rbtext = preg_replace("/\[field:url([\/\s]{0,})\]/isU", $row['url'], $innertext);
echo $rbtext;
$rbtext = preg_replace("/\[field:webname([\/\s]{0,})\]/isU", $row['webname'], $rbtext);
$rbtext = preg_replace("/\[field:logo([\/\s]{0,})\]/isU", $row['logo'], $rbtext);
$rbtext = preg_replace("/\[field:link([\/\s]{0,})\]/isU", $link, $rbtext);
$revalue .= $rbtext;
}
return $revalue;
}
6:dedecms模板调用
{dede:aflink }{/dede:aflink}
最近更新
常用插件
- ecshop二次开发首页显示购
ecshop二次开发首页显示购买记录插件,用图文的方式,来处理在首页显示...
- ecsho成本利润统计分析插件
最近在二次开发ecshop过程中,很多朋友要求一款分析 ecshop成本和利润插...
- ecshop打印快递发货单
ecshop打印快递发货单,这个问题是很常见的问题。在发货完成之后,有些...
- ecshop二次开发直接优惠现
ecshop二次开发促销售功能插件,主要是扩展了ecshop促销功能,增加了更...
- ecshop 匿名下单自动注册会
ecshop 匿名下单自动注册会员...