Jump to content
SliderFlash

Invalid characters: <>; = # {}

Recommended Posts

Posted (edited)

in the categories, Invalid characters: <>; = # {}
I want to allow these characters <> to include an icon image, can you tell me where I can change that?

 

zc.JPG

zd.JPG

Edited by SliderFlash (see edit history)

Share this post


Link to post
Share on other sites

Checks are done in classes/validate.php.

The function for category names is isCatalogName

Share this post


Link to post
Share on other sites
Posted (edited)

 

Quote

in classes/validate.php.

@musicmaster Thanks for the info about validate.php,

I did the following but it still does not work ( see screenshots ) , in my case on PS 1.7 latest version, I am trying to add a <br /> tag ( html line break ) in the category name. In my test I tried to put a hashtag #

726799856_psbug.png.2be824edb172a56a038cbae3515c5a87.png

 

When I put "Category # Test " for example,  I have tried to overwrite the file "Validate.php" , as explained on another topic by redefining the function "isCatalogName"  :

<?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 # but still get the error like on screenshot above. I am using latest version 1.7

I have tried different ways :

- overwritting only the file "Validate.php"
- overwritting Validate.php, but also Category.php and CMSCategory.php where the function "isCatalogName($name)" is called and removing the validation in these files.

- removing the overitten files and editing directly the Core Files in the class directory , then cleared cache, etc.
- I cleared cache in backend and also var/cache files to be sure each time, logged out / logged in administration every time. Refreshed browser cache / Changed browser too !

ps02.jpg.da6e739be1cc56f59f3c9dde944b58f1.jpg

ps01.thumb.jpg.e7a98d8916b309293b6adbeb4ce0aa1e.jpg

It does not work.

 

Edited by mlclm (see edit history)

Share this post


Link to post
Share on other sites
Posted (edited)

./classes/Category.php

find

'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128)

change to

'name' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 65000)

 

Validate.php does not need to be modified

Edited by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites
Posted (edited)

But it will never work.

It will still show the error because it always tries to create a URL from the name.
The most sensible thing is to add your own HTML field and paste the code into it.
A minimum knowledge of Prestashop 5/10 is required for editing.

Edited by D. Tengler (see edit history)

Share this post


Link to post
Share on other sites
Posted (edited)
vor 16 Stunden schrieb D. Tengler:

But it will never work.

It will still show the error because it always tries to create a URL from the name.
The most sensible thing is to add your own HTML field and paste the code into it.
A minimum knowledge of Prestashop 5/10 is required for editing.

I also think that not all characters should be allowed, only for pictures < = " " > otherwise there is a great risk of sql injection.

do you have an idea for a snippet of code? or instructions?

This is possible in PHPBB FORUM, it can be inserted in every category picture icon

Thank you

SF.....

Edited by SliderFlash (see edit history)

Share this post


Link to post
Share on other sites

Am I correct that you're trying to put a picture or category icon in the Menu or category list?

Write the reason for the adjustment to make it understand.

Share this post


Link to post
Share on other sites

yes exactly, a symbol for the categories,
"Pictures are worth a thousand words"
It is better for orientation in the menu and the eyes do not get tired quickly. :)

 

Share this post


Link to post
Share on other sites

Go to ./themes/your-theme/modules/ps_mainmenu/ps_mainmenu.tpl

Find:

{foreach from=$nodes item=node}

add after:

{if $node.image_urls|count}
            {foreach from=$node.image_urls item=image_url}
                <img src="{$image_url}" style="height:32px;margin-right: -10px;">
            {/foreach}
        {/if}

full tpl:

{assign var=_counter value=0}
{function name="menu" nodes=[] depth=0 parent=null}
    {if $nodes|count}
      <ul class="top-menu" {if $depth == 0}id="top-menu"{/if} data-depth="{$depth}">
        {foreach from=$nodes item=node}
        {if $node.image_urls|count}
            {foreach from=$node.image_urls item=image_url}
                <img src="{$image_url}" style="height:32px;margin-right: -10px;">
            {/foreach}
        {/if}
            <li class="{$node.type}{if $node.current} current {/if}" id="{$node.page_identifier}">
            {assign var=_counter value=$_counter+1}
              <a
                class="{if $depth >= 0}dropdown-item{/if}{if $depth === 1} dropdown-submenu{/if}"
                href="{$node.url}" data-depth="{$depth}"
                {if $node.open_in_new_window} target="_blank" {/if}
              >
                {if $node.children|count}
                  {* Cannot use page identifier as we can have the same page several times *}
                  {assign var=_expand_id value=10|mt_rand:100000}
                  <span class="float-xs-right hidden-md-up">
                    <span data-target="#top_sub_menu_{$_expand_id}" data-toggle="collapse" class="navbar-toggler collapse-icons">
                      <i class="material-icons add">&#xE313;</i>
                      <i class="material-icons remove">&#xE316;</i>
                    </span>
                  </span>
                {/if}
                {$node.label}
              </a>
              {if $node.children|count}
              <div {if $depth === 0} class="popover sub-menu js-sub-menu collapse"{else} class="collapse"{/if} id="top_sub_menu_{$_expand_id}">
                {menu nodes=$node.children depth=$node.depth parent=$node}
              </div>
              {/if}
            </li>
        {/foreach}
      </ul>
    {/if}
{/function}

<div class="menu js-top-menu position-static hidden-sm-down" id="_desktop_top_menu">
    {menu nodes=$menu.children}
    <div class="clearfix"></div>
</div>

 

Share this post


Link to post
Share on other sites

It is always better to write in detail what you need to do, make a screen, paint an arrow where you want to edit the code, etc., then the answer is simple and fast.

Share this post


Link to post
Share on other sites

You can give like a click and a gray heart below my posts.

Share this post


Link to post
Share on other sites

You can also put a large category icon in the drop-down menu.
Just put the code before:

{menu nodes=$node.children depth=$node.depth parent=$node}

sample:

{if $node.image_urls|count}
  {foreach from=$node.image_urls item=image_url}
    <img src="{$image_url}" style="height:85px;">
  {/foreach}
{/if}
{menu nodes=$node.children depth=$node.depth parent=$node}

 

result:

obrazek.png.118c240752e11882a26defb82a9d9945.png

Share this post


Link to post
Share on other sites

how did you insert the picture? I get errors, I have inserted the code as described above

 

error.JPG

Share this post


Link to post
Share on other sites

?????????????????

Do not put anything in the category name !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

obrazek.png.93d25fda065400215a06d14472caadc2.png

 

Share this post


Link to post
Share on other sites
Posted (edited)

ok I did not show that first, then I tried another category menu, which was arranged at the top of the menu, it is then displayed.

 

icon.JPG

Edited by SliderFlash (see edit history)

Share this post


Link to post
Share on other sites

With me, no image is displayed like yours no matter what I do

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More