虚位以待(AD)
虚位以待(AD)
首页 > CMS教程 > Ecshop > 两种彻底解决ecshop标题后面的" ..."的方法

两种彻底解决ecshop标题后面的" ..."的方法
类别:Ecshop   作者:码皇   来源:互联网   点击:

经常看到ecshop论坛有人在反应 模板中 设置了{$goods goods_name|truncate:10: } 标题后面还是一样会跟着 这里先给大家讲讲原理 最近发现 ec的模板引擎不完全是smarty 所以在truncate函数上 ,魔客吧
经常看到ecshop论坛有人在反应 模板中 设置了{$goods.goods_name|truncate:10:''} 标题后面还是一样会跟着 ... 这里先给大家讲讲原理 最近发现 ec的模板引擎不完全是smarty 所以在truncate函数上是有区别的 找到 cls_template.php 搜索truncate 你会发现以下代码 case 'truncate': $p = 'sub_str(' . $p . ",$s[1])"; break; 这里的 sub_str是ec的一个自定义函数在 lib_base.php文件中的 代码如下: function sub_str($str, $length = 0, $append = true) { $str = trim($str); $strlength = strlen($str); if ($length == 0 || $length >= $strlength) { return $str; } elseif ($length < 0) { $length = $strlength + $length; if ($length < 0) { $length = $strlength; } } if (function_exists('mb_substr')) { $newstr = mb_substr($str, 0, $length, EC_CHARSET); } elseif (function_exists('iconv_substr')) { $newstr = iconv_substr($str, 0, $length, EC_CHARSET); } else { //$newstr = trim_right(substr($str, 0, $length)); $newstr = substr($str, 0, $length); } if ($append && $str != $newstr) { $newstr .= '...'; } return $newstr; } 其中 仔细看 这个函数有3个参数 但是在模板引擎文件中只代了2个参数 方法一 找到 cls_template.php 搜索truncate case 'truncate': $p = 'sub_str(' . $p . ",$s[1],$s[2])"; break; 然后在你的后台清除一下缓存 1 {$goods.goods_name|truncate:10:false} 就只显示5个字 也不会出现... 方法二 直接干掉lib_base.php中 if ($append && $str != $newstr) { $newstr .= '...'; } 这样{$goods.goods_style_name}也不会显示 ...
相关热词搜索: 两种彻底解决ecshop标题后面的" "的