Prestashop 1.7 添加 <br>类别名称中的特殊字符标签无效,如何在菜单导航导航中拆分字符串? [英] Prestashop 1.7 add <br> special character tag in category name but invalid , how to split string in menu navigation nav?

查看:63
本文介绍了Prestashop 1.7 添加 <br>类别名称中的特殊字符标签无效,如何在菜单导航导航中拆分字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多人都遇到了在产品名称中添加主题标签的类似问题.我正在尝试在 类别名称 中添加一个
标记( html 换行符).我已经把类别
名称"例如,它不会工作.字符验证是为了安全措施,这是有道理的.

A lot of people are having a similar problem for adding a hashtag in the product name. I am trying to add a
tag ( html line break ) in the category name. I have put "Category
name" for example, it won't work. The character validation is there for security measures, it makes sense.

所以我试图覆盖文件Validate.php";,正如在另一个主题中通过重新定义 isCatalogName 函数所解释的那样:

So I have tried to overwrite the file "Validate.php" , as explained on another topic by redefining the isCatalogName function like so :

<?php
class Validate extends ValidateCore
{

    public static function isCatalogName($name)
    {
        // simple test
        
        return !preg_match('/[]/i', $name);
        
    }
}

现在我应该可以像我想要的那样放置像 #<br/> 这样的主题标签,但仍然出现错误.

now I should be able to put a hashtag like # , or <br /> like I wanted, but still get the error.

我尝试了不同的方法:

  • 只覆盖文件Validate.php"
  • 覆盖 Validate.php,还有 Category.php 和 CMSCategory.php,其中函数isCatalogName($name)"被调用并删除这些文件中的验证.
  • 我每次都清除后端缓存和 var/cache 文件以确保每次都退出/登录管理.刷新了浏览器缓存/也更改了浏览器!

有关如何在 Prestashop 1.7 上的类别名称中使用拆分字符串(2 行菜单导航链接)的任何想法?

Any ideas on how to have a split string ( 2 lines menu navigation link ) in the category name on Prestashop 1.7 ?

推荐答案

环顾四周并在 Prestashop 论坛上询问后,我被告知没有简单、直接、无黑客的解决方案来实现这一目标.因为显然为类别选择的名称用于构造 url.这意味着编辑许多核心文件只是为了通过后端>类别字段放置一个特殊字符,这是不合逻辑的.

Well after looking around and asking on the Prestashop forums, I've been told there is no easy-straightforward-hack-free solution to achieve this. Because apparently the name chosen for the category is used to construct the url. This would mean editing many core files just to put a special character via the back-end>categories fields, which is illogic.

所以我只是将其硬编码到文件 modules\ps_mainmenu\*ps_mainmenu.tpl* 中:它适用于我的情况.

So I just hardcoded this into the file modules\ps_mainmenu\*ps_mainmenu.tpl* : it works for my case.

 {* {$node.label} *}


               {if $node.label|strstr:"and"}
                  {assign var="teststring" value=$node.label}
                  {assign var="testsplit" value="and"|explode:$teststring}
                  {$testsplit[0]} <br/> and {$testsplit[1]}
              
                  {elseif $node.label|strstr:","}

                  {if substr_count($node.label, ",") > 1 }

                    {assign var="teststring" value=$node.label}

                    {assign var="label" value=","|explode:$teststring}

                    {$label[0]},<br/>{$label[1]}, {$label|@end}
                    

                  {/if}

我敢肯定,PHP/Smarty 精明的人可以在几行代码中完成此操作,而且效果更好(请告诉我!)但它对我有用.(在某些情况下添加
)

I'm sure someone PHP/Smarty savy could do this in a few lines and much nicer ( let me know please! ) but it works for me. (adding <br/> in some cases)

这篇关于Prestashop 1.7 添加 &lt;br&gt;类别名称中的特殊字符标签无效,如何在菜单导航导航中拆分字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆