用织梦仿站时候,经常会使用currentstyle标签高亮当前的栏目,具体代码为:
currentstyle=~typename~
但是在实际建站操作中经常调用自定义字段,大伙会发现在用currentstyle的时候读取不出自定义字段的内容了。这时候,就需要对织梦进行二次开发,以满足的需要。
1 | 打开/include/taglib/channel.lib.php文件,在136行找到:
$row[ ypelink]=GetOneTypeUrlA($row);
2 | 按照格式规则写入需要调用的自定义字段。例如,要调用abcd字段名,那么就这样写:
$linkOkstr=str_replace("~abcd~",$row[abcd],$linkOkstr);
示例:
//处理同级栏目中,当前栏目的样式if(($row[id]==$typeid||($topid==$row[id]&&$type== op))&&$currentstyle!=\){$linkOkstr=$currentstyle;$row[ ypelink]=GetOneTypeUrlA($row);$linkOkstr=str_replace("~abcd~",$row[abcd],$linkOkstr);//这一句就是新增的字段名$linkOkstr=str_replace("~rel~",$row[ el],$linkOkstr);$linkOkstr=str_replace("~id~",$row[id],$linkOkstr);$linkOkstr=str_replace("~typelink~",$row[ ypelink],$linkOkstr);$linkOkstr=str_replace("~typename~",$row[ ypename],$linkOkstr);$likeType.=$linkOkstr;}
3 | 现在就可以在currentstyle中用~abcd~来调取相应的内容了。