amando96 Posted May 18, 2014 Share Posted May 18, 2014 So I've been following prestashop's tutorial on how to make modules, it works fine in the backoffice, I can set variables, etc. But it simply will not show in the front office, I'm using the default bootstrap theme, and prestashop 1.6. I added echos and die() in the hookDisplayLeftColumn(), but they didn't affect anything, it's like it isn't even being executed. I did everything exactly like the tutorial says, I don't know why this isn't working. The hook is registered in the database. I get no errors, no logs, nothing. Any ideas? Problem is exactly like this, but there was no solution there. Link to comment Share on other sites More sharing options...
vekia Posted May 18, 2014 Share Posted May 18, 2014 show your code please your module is correctly hooked to displayLeftColumn ? Link to comment Share on other sites More sharing options...
amando96 Posted May 18, 2014 Author Share Posted May 18, 2014 (edited) <?php /* File: urlshortener.php Author: Amando Filipe, mndstudios.com Date created: 16-05-2014 Last modified: 17-05-2014 */ if (!defined('_PS_VERSION_')) exit; class UrlShortener extends Module { public function __construct() { $this->name = 'urlshortener'; $this->tab = 'seo'; $this->version = '0.5'; $this->author = 'mndStudios'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6'); $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('URL Shortener'); $this->description = $this->l('short urls (yourdomain.com/shorturl)'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('URLSHORTENER_NAME')) $this->warning = $this->l('No name provided'); } public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('header') || !Configuration::updateValue('URLSHORTENER_NAME', 'URL Shortener') ) return false; return true; } public function uninstall() { if (!parent::uninstall() || !Configuration::deleteByName('URLSHORTENER_NAME') || !Configuration::deleteByName('URLSHORTENER_TEST') ) return false; return true; } public function getContent() { $output = null; if (Tools::isSubmit('submit'.$this->name)) { $my_module_name = strval(Tools::getValue('URLSHORTENER_NAME')); if (!$my_module_name || empty($my_module_name) || !Validate::isGenericName($my_module_name)) $output .= $this->displayError($this->l('Invalid Configuration value')); else { Configuration::updateValue('URLSHORTENER_NAME', $my_module_name); $output .= $this->displayConfirmation($this->l('Settings updated')); } } return $output.$this->displayForm(); } public function displayForm() { // Get default language $default_lang = (int)Configuration::get('PS_LANG_DEFAULT'); // Init Fields form array $fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('Settings'), ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Configuration value'), 'name' => 'URLSHORTENER_NAME', 'size' => 20, 'required' => true ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); $helper = new HelperForm(); // Module, token and currentIndex $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; // Language $helper->default_form_language = $default_lang; $helper->allow_employee_form_lang = $default_lang; // Title and toolbar $helper->title = $this->displayName; $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->submit_action = 'submit'.$this->name; $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); // Load current value $helper->fields_value['URLSHORTENER_NAME'] = Configuration::get('URLSHORTENER_NAME'); $helper->fields_value['URLSHORTENER_TEST'] = Configuration::get('URLSHORTENER_TEST'); return $helper->generateForm($fields_form); } public function hookDisplayLeftColumn($params) { $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('URLSHORTENER_NAME'), 'my_module_link' => $this->context->link->getModuleLink('URLSHORTENER', 'display') ) ); return $this->display(__FILE__, 'urlshortener.tpl'); } public function hookDisplayRightColumn($params) { return $this->hookDisplayLeftColumn($params); } public function hookDisplayHeader() { $this->context->controller->addCSS($this->_path.'css/urlshortener.css', 'all'); } urlshortener.php Sorry about no indentation. ignore the test variable, I deleted parts of it but it didn't work when it was okay either, so that isn't it. Edited May 18, 2014 by amando96 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 18, 2014 Share Posted May 18, 2014 i checked this on my own installation everything works make sure that: - your module is attached to displayLeftColumn hook under modules > positions tab in back office in addition, make sure that your left column is enabled! Link to comment Share on other sites More sharing options...
amando96 Posted May 18, 2014 Author Share Posted May 18, 2014 (edited) I still don't get what I'm expecting(the TPL output), what exactly did you try/get? Edit: Added the hookDisplayFooter method and transplanted it, works fine, as far I understand the LeftColumn is active in the themes tab... Edited May 18, 2014 by amando96 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 18, 2014 Share Posted May 18, 2014 module is properly hooked to the column hook, when im browsing front office it informs me that there is no .tpl file so if you will create .tpl file (as I did) it will appear instead of message about missing template. Link to comment Share on other sites More sharing options...
amando96 Posted May 19, 2014 Author Share Posted May 19, 2014 Doesn't here, when hooked to the left column nothing happens. Link to comment Share on other sites More sharing options...
vekia Posted May 19, 2014 Share Posted May 19, 2014 i know that sounds weird but... have you got left column? Link to comment Share on other sites More sharing options...
amando96 Posted May 20, 2014 Author Share Posted May 20, 2014 The theme options say I do, does the default-bootstrap have a left column? Link to comment Share on other sites More sharing options...
vekia Posted May 20, 2014 Share Posted May 20, 2014 yes it doesnt have, for example, on homepage there is no left column by default. can you show screenshot of page where you're trying to check 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