cedced Posted April 29, 2015 Share Posted April 29, 2015 Hi, I've managed to have the TinyMCE attached to the CMS Category and when I use it to format the text it works fine. However when I save the page, nothing is saved : the formatting doesn't show on the frontend and if I edit back the cms category page, although TinyMCE is still there, the formatting is reset. Has anyone put in place TinyCME for the CMS category description or would know what to correct for the formatting to be saved? Thanks Link to comment Share on other sites More sharing options...
vekia Posted June 2, 2015 Share Posted June 2, 2015 what is exact number of your prestashop? 1.6.x.y ? Link to comment Share on other sites More sharing options...
vadimda Posted July 29, 2015 Share Posted July 29, 2015 what is exact number of your prestashop? 1.6.x.y ? same question prestashop 1.6.1.0 tried this solution, the editor appeared but when saving the whole HTML code is reset Link to comment Share on other sites More sharing options...
vadimda Posted November 27, 2015 Share Posted November 27, 2015 (edited) Prestashop 1.6.1.2 1. Add TinyMCE editor to cms category description field 'autoload_rte' => true create overriding file /override/controllers/admin/AdminCmsCategoriesController.php <?php Class AdminCmsCategoriesController extends AdminCmsCategoriesControllerCore { public function renderForm() { $this->display = 'edit'; $this->initToolbar(); if (!$this->loadObject(true)) { return; } $categories = CMSCategory::getCategories($this->context->language->id, false); $html_categories = CMSCategory::recurseCMSCategory($categories, $categories[0][1], 1, $this->getFieldValue($this->object, 'id_parent'), 1); $this->fields_form = array( 'legend' => array( 'title' => $this->l('CMS Category'), 'icon' => 'icon-folder-close' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => true, 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'switch', 'label' => $this->l('Displayed'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), // custom template array( 'type' => 'select_category', 'label' => $this->l('Parent CMS Category'), 'name' => 'id_parent', 'options' => array( 'html' => $html_categories, ), ), array( 'type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'rows' => 5, 'cols' => 40, 'hint' => $this->l('Invalid characters:').' <>;=#{}', 'autoload_rte' => true ), array( 'type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'hint' => $this->l('Invalid characters:').' <>;=#{}' ), array( 'type' => 'text', 'label' => $this->l('Friendly URL'), 'name' => 'link_rewrite', 'required' => true, 'lang' => true, 'hint' => $this->l('Only letters and the minus (-) character are allowed.') ), ), 'submit' => array( 'title' => $this->l('Save'), ) ); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso', ); } $this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); return AdminController::renderForm(); } } ?> 2. Let the prestashop save html code, replacing cms category desription field type from TYPE_STRING to TYPE_HTML create overriding file /override/classes/CMSCategory.php <?php class CMSCategory extends CMSCategoryCore { public static $definition = array( 'table' => 'cms_category', 'primary' => 'id_cms_category', 'multilang' => true, 'multilang_shop' => true, 'fields' => array( 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), 'id_parent' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), 'position' => array('type' => self::TYPE_INT), 'level_depth' => array('type' => self::TYPE_INT), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), /* Lang fields */ 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 64), 'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 64), 'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'), 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 128), 'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), 'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255), ), ); } ?> 3.Go to your theme folder, open cms.tpl, find <p>{$cms_category->description|escape:'html':'UTF-8'}</p> replace to <div>{$cms_category->description}</div> 4. Dont forget to delete class_index.php in the /cache folder Edited November 27, 2015 by vadimda (see edit history) 5 Link to comment Share on other sites More sharing options...
Scott J Posted February 16, 2016 Share Posted February 16, 2016 Thank you, thank you - you are brilliant! On my own, i could work out the last step, but would have no hope figuring out the rest of it. Link to comment Share on other sites More sharing options...
contactovisual Posted March 17, 2016 Share Posted March 17, 2016 (edited) Vadimda solution worked very well. Should be something to add on a next update of Prestashop. It's a must. I add it to Prestashop 1.6.1.4 Thank you Nelson / Contacto Visual Edited March 17, 2016 by contactovisual (see edit history) Link to comment Share on other sites More sharing options...
motorevolution Posted March 17, 2016 Share Posted March 17, 2016 (edited) Hi everyone, I am glad somebody could fix this for PS 1.6.1.4. I also need to have tinymce and html code in Category description. Could someone teach me how to do it, please? Thanks in advance. Adrian. P.S. My first instict is to copy the solution for CMS category description and just delete the "CMS" out of it... Will that work or is there a different approach? Edited March 17, 2016 by motorevolution (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now