Dedecms 模板中心

您现在的位置: 首页 > 教程文档 > 织梦技巧 >

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

来源:未知 发布时间:2016-05-31热度:
dede的友情链接标签设定行了列后,生成的是tabletrtd代码来控制行数和列数 如果模板使用xhtml+css编写,想用li来表示链接结构就很方便。 ================================================================= 修改方法: 首先打开include/inc_arcpart_view.p...

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.gooddede.com' target='_blank'>好织梦</a></li>
</ul> 
<div>

相关属性请自行定义。

    责任编辑:好织梦