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.
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);
}
}
now I should be able to put a hashtag like #
, or <br />
like I wanted, but still get the error.
I have tried different ways :
Any ideas on how to have a split string ( 2 lines menu navigation link ) in the category name on Prestashop 1.7 ?
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.
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}
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)