giwrgos88 Posted April 18, 2018 Share Posted April 18, 2018 (edited) Hello, I'm working on a module for prestashop 1.7 and 1.6 (I'm testing it on 1.7) and I want to display some information on the single page of a product and for that reason I used the displayRightColumnProduct hook. The issue is that I cannot see the content that I'm printing from displayRightColumnProduct but If i go to Design -> Positions I can see my module on the right column product section. Here is my code <?php if (!defined('_PS_VERSION_')) { exit; } class Rating extends Module { public function __construct() { $this->name = 'rating'; $this->tab = 'front_office_features'; $this->version = '0.0.0'; $this->author = 'George Panayi'; $this->ps_versions_compliancy = ['min' => '1.6', 'max' => _PS_VERSION_]; $this->bootstrap = true; $this->controllers = []; parent::__construct(); $this->displayName = $this->l('Rating'); $this->description = $this->l('Test module'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); $this->page = basename(__FILE__, '.php'); } public function install() { if (!parent::install() || !$this->registerHook('displayRightColumnProduct') ) { return false; } return true; } public function uninstall() { if (!parent::uninstall() ) { return false; } return true; } public function hookdisplayRightColumnProduct($params) { return $this->display(__FILE__, 'rating.tpl'); } } Here is my rating.tpl (mymodulename/views/templates/hook/rating.tpl) This is a test Do you know what I'm doing wrong? Edited April 24, 2018 by giwrgos88 Added module class (see edit history) Link to comment Share on other sites More sharing options...
tdsoft Posted April 18, 2018 Share Posted April 18, 2018 That source only display in RIGHT column of website - When you view a product detail page -> No RIGHT column in this page -> Nothing display - When you view some another pages -> It have displayRightColumn hook But $product = new Product((int) Tools::getValue('id_product')); -> NOT EXIST id_product So this block code will be executed if (!Validate::isLoadedObject($product)) { return false; } Function returned: FALSE it does not load template Link to comment Share on other sites More sharing options...
giwrgos88 Posted April 18, 2018 Author Share Posted April 18, 2018 @tdsoft As I said I want to display it in the single product page, not on the category page that's why I'm using the displayRightColumnProduct. As for the $product = new Product((int) Tools::getValue('id_product')) you are right but event if you do var_dump or just return the tpl file with static text it doesn't display it. Link to comment Share on other sites More sharing options...
Radhanatha Posted April 24, 2018 Share Posted April 24, 2018 (edited) Hi All, Below codes are working fine for me. Please check all. First Go To PrestaShop Admin->Design->Theme & Logo > Theme On Left Side page column value "product" ->assign layout to value "Two Columns, small right column - Two columns with a small right column". Please check below screenshot. Then Create a custom module as per your requirement. Module: ---------- <?php if (!defined('_PS_VERSION_')) { exit; } // Code for Order Download End class letfColumnProduct extends Module { /* @var boolean error */ protected $_errors = false; public function __construct() { $this->name = 'letfcolumnproduct'; $this->tab = 'letfcolumnproduct'; $this->version = '1.0.0'; $this->author = 'Radhanatha'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('InkXE Letf Button'); $this->description = $this->l('Integrates the Letf Column Button on Product Details Page.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_NAME')) { $this->warning = $this->l('No name provided'); } } /** * Installation code of this module * * @param NULL * */ public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } return parent::install() && // CUSTOMIZE BUTTON HOOKS $this->registerHook('displayRightColumnProduct') && Configuration::updateValue('MYMODULE_NAME', 'shopping cart changes'); } /** * Un-instal code of this module * * @param NULL * */ public function uninstall() { if (!parent::uninstall()) { return false; } return true; } /** * Show product custom buton in store front end * * @param NULL * */ public function hookDisplayRightColumnProduct() { $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->context->link->getModuleLink('letfcolumnproduct', 'display'), ) ); return $this->display(__FILE__, 'letfcolumnproduct.tpl'); } } Edited April 24, 2018 by Radhanatha (see edit history) 1 Link to comment Share on other sites More sharing options...
Chill_user Posted April 17, 2019 Share Posted April 17, 2019 You need to enable 3 columns layout, then you will see it 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