xhtml+css模板中,友情链接标签生成的修改_DedeCms教程
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>
相关属性请自行定义。
- Dedecms生成百度地图图文教程
- 织梦dedecms生成下拉式友情链接列表
- DEDECMS使用拼音首字母做栏目名称
- 织梦DEDECMS站群增强版 DedeCMS搭建站群首选
- DedeCMS Error:Tag disabled:php错误的完整处理方法
- dedecms编码转换方法 gbk转UTF-8,UTF-8转GBK
- 防XSS,sql注射,代码执行,文件包含的通用代码
- DedeCms教程:优化DedeCMS搜索结果
- DedeCms教程:Linux+Apache+PHP+MySQL服务器环境(CentOS篇)
- DedeCms教程:LuManager服务器管理软件安装DEDECMS软件
- DedeCms教程:Ubuntu/Debian上安装 PHP 5.3, Nginx 和 PHP-fpm
- DedeCms教程:windows server 2003 php 环境搭建