rick0012 Posted July 30, 2023 Share Posted July 30, 2023 I have created my first custom prestashop(v8) module. For some reason the tpl file is getting html encoded in the website frontend. I inspected the site code and noticed the tpl file content is getting added to the site as follow <div class="product-additional-info"> <label for="custom_instructions">Custom Instructions</label> <textarea id="custom_instructions" name="custom_instructions" rows="4" cols="50"></textarea> </div> You see how <label became <label the corresponding tpl file for this looks like this <label for="custom_instructions">{l s='Custom Instructions'}</label> <textarea id="custom_instructions" name="custom_instructions" rows="4" cols="50"></textarea> Do you have any ideas or suggestions as to why this is happening? Please check the screenshot of how it looks on the site frontend because of the html encoding. Here is the relevant php code <?php class custominstructions extends Module { public function __construct() { $this->name = 'custominstructions'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Sayantan Roy'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Custom Instructions'); $this->description = $this->l('Add a text box for custom instructions on the product page.'); // Set the module's bootstrap status to true $this->bootstrap = true; } public function install() { if (!parent::install() || !$this->registerHook('displayProductAdditionalInfo') || !$this->registerHook('actionValidateOrder') || !$this->registerHook('displayAdminOrder')) { return false; } return true; } public function uninstall() { if (!parent::uninstall()) { return false; } return true; } public function hookDisplayProductAdditionalInfo($params) { $this->context->smarty->assign(array( 'custom_instructions' => $this->display(__FILE__, 'views/templates/hook/custom_instructions.tpl'), )); return $this->display(__FILE__, 'views/templates/hook/product_additional_info.tpl'); } public function hookActionValidateOrder($params) { $order = $params['order']; $customInstructions = Tools::getValue('custom_instructions'); if (!empty($customInstructions)) { // Save the custom instructions to the order Db::getInstance()->insert('order_message', array( 'id_order' => (int)$order->id, 'message' => pSQL($customInstructions), )); } } public function hookDisplayAdminOrder($params) { $orderId = (int)Tools::getValue('id_order'); $orderMessages = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'order_message` WHERE `id_order` = '.$orderId); $this->context->smarty->assign(array( 'orderMessages' => $orderMessages, )); return $this->display(__FILE__, 'views/templates/admin/custom_instructions_order.tpl'); } } Link to comment Share on other sites More sharing options...
ps8modules Posted July 30, 2023 Share Posted July 30, 2023 In TPL: {$your_variable nofilter} Link to comment Share on other sites More sharing options...
rick0012 Posted July 30, 2023 Author Share Posted July 30, 2023 (edited) 16 minutes ago, ps8moduly.cz said: In TPL: {$your_variable nofilter} should I use it like this? {l s='Custom Instructions' nofilter } When I change the tpl to this then the content is no longer visible on frontend. Edited July 30, 2023 by rick0012 (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted July 30, 2023 Share Posted July 30, 2023 {$custom_instructions nofilter} 1 Link to comment Share on other sites More sharing options...
rick0012 Posted July 30, 2023 Author Share Posted July 30, 2023 9 minutes ago, ps8moduly.cz said: {$custom_instructions nofilter} Thank you! it worked. 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