Guillaume_KS Posted August 13, 2022 Share Posted August 13, 2022 Je suis sur Prestashop 1.7 et je voudrais ajouter un champ ysiwyg personnalisé dans la page de la catégorie de produit et pouvoir afficher sa valeur dans le front-office. J'ai déjà réussi à mettre en place le champ wysiwyg dans le back-office mais je n'arrive pas à récupérer la valeur pour l'insérer dans le modèle et l'afficher côté client. Voici mon module : <?php if (!defined('_PS_VERSION_')) exit; class Wysi extends Module { public function __construct() { $this->name = 'wysi'; $this->tab = 'front_office_features'; $this->version = '0.1'; $this->author = 'advisa'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('wysi'); $this->description = $this->l('Add WYSIWYG field in Product Category'); } public function install() { return parent::install() && $this->registerHook('displayBackOfficeCategory'); } public function uninstall() { return parent::uninstall(); } public function hookDisplayBackOfficeCategory($params) { return $this->display(__FILE__, 'wysi.tpl'); } Et voici mon template qui affiche le champ wysiwyg <label for="texteSeo">Texte SEO</label><br> <textarea class= "autoload_rte" id="id" name="name" rows="10" cols="45"></textarea> Merci d'avance !! Link to comment Share on other sites More sharing options...
Ali Samie Posted August 14, 2022 Share Posted August 14, 2022 Pourquoi avez-vous besoin d'ajouter ce champ ? Link to comment Share on other sites More sharing options...
Guillaume_KS Posted August 14, 2022 Author Share Posted August 14, 2022 Dans le cadre d'un exercice, mais j'ai beau avoir chercher, je ne vois pas comment procéder Link to comment Share on other sites More sharing options...
Guillaume_KS Posted August 14, 2022 Author Share Posted August 14, 2022 (edited) J'ai tenter de faire un override mais j'ai un problème avec du coup <?php if (!defined('_PS_VERSION_')) exit; class Wysi extends Module { public function __construct() { $this->name = 'wysi'; $this->tab = 'front_office_features'; $this->version = '0.1'; $this->author = 'advisa'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('wysi'); $this->description = $this->l('Add WYSIWYG field in Product Category'); } public function install() { return parent::install() && $this->registerHook('displayBackOfficeCategory'); } public function uninstall() { return parent::uninstall(); } public function _installSql() { $sqlInstall = "ALTER TABLE " . _DB_PREFIX_ . "category_lang ADD composition TEXT null"; $returnSql = Db::getInstance()->execute($sqlInstall); return $returnSql; } public function hookDisplayBackOfficeCategory($params) { $texteSeo = new Category($params['id_texteSeo']); $this->context->smarty->assign(array( 'texteSeo' => $texteSeo->composition, )); return $this->display(__FILE__, 'wysi.tpl'); } } class Category extends CategoryCore { public $composition; public function __construct( $id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null ) { self::$definition['fields']['composition'] = array( 'type' => self::TYPE_HTML, 'lang' => false, 'required' => false, 'validate' => 'isCleanHtml' ); parent::__construct($id_product, $full, $id_lang, $id_shop, $context); } } Dans le back-office je reçois l'erreur suivante : Quote [Semantical Error] The annotation "@AdminSecurity" in method PrestaShopBundle\Controller\Admin\Sell\Catalog\CategoryController::indexAction() was never imported. Did you maybe forget to add a "use" statement for this annotation? Donc j'ai essayer de mettre use PrestaShopBundle\Controller\Admin\Sell\Catalog\CategoryController Mais cela ne change pas ce message d'erreur Edited August 14, 2022 by Guillaume_KS (see edit history) Link to comment Share on other sites More sharing options...
Guillaume_KS Posted August 14, 2022 Author Share Posted August 14, 2022 Quelqu'un peut m'aider svp ? Link to comment Share on other sites More sharing options...
Mediacom87 Posted August 14, 2022 Share Posted August 14, 2022 Peut-être trouverez vous votre bonheur dans la documentation https://devdocs.prestashop.com/1.7/modules/sample-modules/ Link to comment Share on other sites More sharing options...
wack Posted August 15, 2022 Share Posted August 15, 2022 Au pire, tu as ce module : https://addons.prestashop.com/fr/onglet-produit/29193-champs-personnalises-avances-creer-de-nouveaux-champs.html 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