Jump to content

Category Description with html-tags?


rethus
 Share

Recommended Posts

I search for a way to use styling elements in the Category-Description.
Is there a way to use it?
If i enter

or other tags, after saving all those tags are gone. Only the

tag is still in this Sourcecode.

BTW: How can i set the Category-Description to the bottom of the page, or add another description-field for the categories?

Share this post


Link to post
Share on other sites

  • 1 month later...

To your first question, there is a solution yes, although it involves editing core files. Solution thanks to:
http://www.prestashop.com/forums/viewthread/21118/P30/#261603

This is a translated version of his solution:

Bonjour,
You only have to modify one file:
in classes/Category.php line 98 function "getTranslationsFieldsChild" :

replace :
public function getTranslationsFieldsChild()
   {
       parent::validateFieldsLang();
       return parent::getTranslationsFields(array('name', 'description', 'link_rewrite', 'meta_title', 'meta_keywords', 'meta_description'));
   }



by :

public function getTranslationsFieldsChild()
   {
       self::validateFieldsLang();

       $fieldsArray = array('name', 'link_rewrite', 'meta_title', 'meta_keywords', 'meta_description');
       $fields = array();
       $languages = Language::getLanguages();
       $defaultLanguage = Configuration::get('PS_LANG_DEFAULT');
       foreach ($languages as $language)
       {
           $fields[$language['id_lang']]['id_lang'] = $language['id_lang'];
           $fields[$language['id_lang']][$this->identifier] = intval($this->id);
           $fields[$language['id_lang']]['description'] = (isset($this->description[$language['id_lang']])) ? Tools::htmlentitiesDecodeUTF8(pSQL($this->description[$language['id_lang']], true)) : '';
           foreach ($fieldsArray as $field)
           {
               if (!Validate::isTableOrIdentifier($field))
                   die(Tools::displayError());

               /* Check fields validity */
               if (isset($this->{$field}[$language['id_lang']]) AND !empty($this->{$field}[$language['id_lang']]))
                   $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']]);
               elseif (in_array($field, $this->fieldsRequiredLang))
                   $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage]);
               else
                   $fields[$language['id_lang']][$field] = '';
           }
       }
       return $fields;
   }





It works under 1.2.4, 1.2.5 and reportedly also under 1.3
  • Like 1

Share this post


Link to post
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 4 weeks later...
  • 3 months later...
  • 2 weeks later...
  • 10 months later...

I would like to warn and say this does not fully work with the current versions of PrestaShop (it does if you read the edit-part below!). Sure, it can create links (

<a href="http://www.google.com/">Testlänk</a>

). But when looking at the source code it looks like this:

1zr2634.jpg

It doesn't look really right.. anyone got a solution for this or does it acutally matter?

 

--

 

Edit: Now when I removed the code and replaced it with the old one the link still remains in the description and the source code looks a lot more clean.

 

So a simple but a bit amateurish solution would be to use the code when you wanna edit the description with HTML-tags, save the description and then replace the new code with the old one (referring to the category.php code in /classes/).

Edited by Noyes (see edit history)

Share this post


Link to post
Share on other sites

  • 6 months later...
  • 8 years later...

 

On 2/10/2011 at 4:31 PM, rethus said:

I search for a way to use styling elements in the Category-Description.
Is there a way to use it?
If i enter

or other tags, after saving all those tags are gone. Only the

tag is still in this Sourcecode.

BTW: How can i set the Category-Description to the bottom of the page, or add another description-field for the categories?

Found a solution:
Prestashop 1.7.7.4
This is already solved in classes/category.php model with a method called getDescriptionClean().

You just need to do a trick in tpl files. Where ever you want to use category description you need to write like this:

{$category.description nofilter}

 

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
 Share

×
×
  • Create New...

Important Information

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