下文来给各位重点介绍phpcms V9标题样式标签{title_style($v[style])}改进,希望例子能帮助到各位.
在loop里面使用了{title_style($v[style])}标题样式,如果当前标题不存在样式,高亮、加粗,就会生成多余的废弃代码 style="" ,如:<a href="{$v['url']}" target="_blank" style="">标题</a>
看了不舒服吧.
修改:phpcmslibsfunctionsglobal.func.php 1476行开始,代码如下:
- /**
- * 生成标题样式
- * @param $style 样式
- * @param $html 是否显示完整的STYLE
- */
- function title_style($style, $html = 1) {
- $str = '';
- if ($html) $str = ' style="';
- $style_arr = explode(';',$style);
- if (!emptyempty($style_arr[0])) $str .= 'color:'.$style_arr[0].';';
- if (!emptyempty($style_arr[1])) $str .= 'font-weight:'.$style_arr[1].';';
- if ($html) $str .= '" '; //www.phpcms.vip
- return $str;
- }
修改成,代码如下:
- /**
- * 生成标题样式
- * @param $style 样式
- * @param $html 是否显示完整的STYLE
- */
- function title_style($style, $html = 1) {
- if (!emptyempty($style)){
- $str = '';
- if ($html) $str = ' style="';
- $style_arr = explode(';',$style);
- if (!emptyempty($style_arr[0])) $str .= 'color:'.$style_arr[0].';';
- if (!emptyempty($style_arr[1])) $str .= 'font-weight:'.$style_arr[1].';';
- if ($html) $str .= '"';
- return $str;
- }
- }