轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 ECShop网店 查看主题

修改ecshop删除解决商品名称标题后面的省略号...

发布者: 觉醒的白河愁 | 发布时间: 2018-6-12 02:25| 查看数: 5158| 评论数: 1|帖子模式

[url=http://www.qingyuanma.com/forum-43-1.html]ecshop[/url]模板中设置了{$goods.goods_name|truncate:10:''}标题后面还是一样会跟着省略号 ... 该如何解决:
提供该:
1.首先ecshop的模板引擎不完全是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个参数
2. 以下提供两种方法修改:
方法一
找到 cls_template.php 搜索truncate
case 'truncate':
$p = 'sub_str(' . $p . ",$s[1],$s[2])";
break;

然后在你的后台清除一下缓存
{$goods.goods_name|truncate:10:false}
就只显示5个字 也不会出现...

方法二
直接用代码删除页面显示中的省略号,找到lib_base.php中
    if ($append && $str != $newstr)
    {
        $newstr .= '...';
    }

这样{$goods.goods_style_name}也不会显示 ...

最新评论

Ontheroad 发表于 2022-6-25 08:29
查看网页源代码怎么下载视频

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表