xhtml+css模板中,友情链接标签生成的修改_DedeCms教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

dede的友情链接标签设定行了列后,生成的是<table><tr><td>代码来控制行数和列数

如果模板使用xhtml+css编写,想用<li>来表示链接结构就很方便。

=================================================================

修改方法:
首先打开include/inc_arcpart_view.php 文件

找到:(720-764行)

//获取友情链接列表
//------------------------
function GetFriendLink($type="",$row="",$col="",$titlelen="",$tablestyle="",$linktype=1,$innertext=''){
$type = AttDef($type,"textall");
$row = AttDef($row,4);
$col = AttDef($col,6);
if($linktype=="") $linktype = 1;
$titlelen = AttDef($titlelen,24);
$tablestyle = AttDef($tablestyle," width='100%' border='0' cellspacing='1' cellpadding='1' ");
$tdwidth = round(100/$col)."%";
$totalrow = $row*$col;

if($innertext=='') $innertext = " [field:link/] ";

$wsql = " where ischeck >= '$linktype' ";
if($type=="image") $wsql .= " And logo<>'' ";
else if($type=="text") $wsql .= " And logo='' ";
else $wsql .= "";

$equery = "Select * from dede_flink $wsql order by sortrank asc limit 0,$totalrow";

$this->dsql->SetQuery($equery);
$this->dsql->Execute();

$revalue = "";
while($row = $this->dsql->GetArray())
{
if($type=="text"||$type=="textall")
$row['link'] = "<a href='".$row['url']."' target='_blank'>".cn_substr($row['webname'],$titlelen)."</a>";
else if($type=="image")
$row['link'] = "<a href='".$row['url']."' target='_blank'><img alt='".str_replace("'","`",$row['webname'])."' src='".$row['logo']."' border='0'></a>";
else{
if($row['logo']=="")
$row['link'] = " <a href='".$row['url']."' target='_blank'>".cn_substr($row['webname'],$titlelen)."</a>";
else
$row['link'] = " <a href='".$row['url']."' target='_blank'><img alt='".str_replace("'","`",$row['webname'])."' src='".$row['logo']."' border='0'></a>";
}
$rbtext = preg_replace("/\[field:url([\s]{0,})\/\]/isU",$row['url'],$innertext);
$rbtext = preg_replace("/\[field:webname([\s]{0,})\/\]/isU",$row['ID'],$rbtext);
$rbtext = preg_replace("/\[field:logo([\s]{0,})\/\]/isU",$row['logo'],$rbtext);
$rbtext = preg_replace("/\[field:link([\s]{0,})\/\]/isU",$row['link'],$rbtext);
$revalue .= $rbtext;
}
return $revalue;
}

修改为:

//获取友情链接列表
//------------------------
function GetFriendLink($type="",$row="",$col="",$titlelen="",$tablestyle="",$linktype=1,$innertext=''){
$type = AttDef($type,"textall");
$row = AttDef($row,4);
$col = AttDef($col,6);
if($linktype=="") $linktype = 1;
$titlelen = AttDef($titlelen,24);
$tablestyle = AttDef($tablestyle," width='100%' border='0' cellspacing='1' cellpadding='1' ");
$tdwidth = round(100/$col)."%";
$totalrow = $row*$col;

if($innertext=='') $innertext = " [field:link/] ";

$wsql = " where ischeck >= '$linktype' ";
if($type=="image") $wsql .= " And logo<>'' ";
else if($type=="text") $wsql .= " And logo='' ";
else $wsql .= "";

$equery = "Select * from dede_flink $wsql order by sortrank asc limit 0,$totalrow";

$this->dsql->SetQuery($equery);
$this->dsql->Execute();

$revalue = "";
while($row = $this->dsql->GetArray())
{
if($type=="text"||$type=="textall")
$row['link'] = "<li><a href='".$row['url']."' target='_blank'>".cn_substr($row['webname'],$titlelen)."</a></li>";
else if($type=="image")
$row['link'] = "<li><a href='".$row['url']."' target='_blank'><img alt='".str_replace("'","`",$row['webname'])."' src='".$row['logo']."' border='0'></a></li>";
else{
if($row['logo']=="")
$row['link'] = " <li><a href='".$row['url']."' target='_blank'>".cn_substr($row['webname'],$titlelen)."</a></li>";
else
$row['link'] = " <li><a href='".$row['url']."' target='_blank'><img alt='".str_replace("'","`",$row['webname'])."' src='".$row['logo']."' border='0'></a></li>";
}
$rbtext = preg_replace("/\[field:url([\s]{0,})\/\]/isU",$row['url'],$innertext);
$rbtext = preg_replace("/\[field:webname([\s]{0,})\/\]/isU",$row['ID'],$rbtext);
$rbtext = preg_replace("/\[field:logo([\s]{0,})\/\]/isU",$row['logo'],$rbtext);
$rbtext = preg_replace("/\[field:link([\s]{0,})\/\]/isU",$row['link'],$rbtext);
$revalue .= $rbtext;
}
return $revalue;
}

模板中的调用标签:

<div class="flink"><ul>
{dede:flink type='textall' titlelen='24' }{/dede:flink}
</ul>
<div>


调用后生成效果:
<div class="flink"><ul>
<li><a href='http://www.dedecms.com' target='_blank'>DEDECMS</a></li>
<li><a href='http://www.mb5u.com' target='_blank'>模板无忧</a></li>
</ul>
<div>

相关属性请自行定义。

官方原帖:http://bbs.dedecms.com/read.php?tid=52250&fpage=3

查看更多 DedeCms教程  织梦模板  织梦DedeCms视频教程  织梦dedecms专题

来源:DEDECMS论坛//所属分类:DedeCms教程/更新时间:2008-03-07
相关DedeCms教程