Kerm Posted June 4, 2012 Share Posted June 4, 2012 (edited) Hello, i know how do new hook and put it to the site template and all work fine, i see my module in new hook, but when i try put hook in module template i see this error: Notice: Undefined variable: HOOK_HEADER_..... How can i put new hook directly to the module template? I just need in one module put hook to load other module... Edited June 4, 2012 by Kerm (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted June 4, 2012 Share Posted June 4, 2012 it is just a smarty variable, so you would do something like {$HOOK_HEADER} Link to comment Share on other sites More sharing options...
Kerm Posted June 4, 2012 Author Share Posted June 4, 2012 Hello, thanks for fast reply. What i do: FrontController.php 1) Near line 500 i add: 'HOOK_HEADER_DEM' => Module::hookExec('headeruserinfo') // New Hook 2) After in mysql table ps_hook i add new hook 3) After in module "blockuserinfo" add new hook: return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header') AND $this->registerHook('headeruserinfo')); At the end of file i add: public function hookheaderuserinfo($params) { if (!$this->active) return; global $smarty, $cookie, $cart; $smarty->assign(array( 'cart' => $cart, 'cart_qties' => $cart->nbProducts(), 'logged' => $cookie->isLogged(), 'customerName' => ($cookie->logged ? $cookie->customer_firstname.' '.$cookie->customer_lastname : false), 'firstName' => ($cookie->logged ? $cookie->customer_firstname : false), 'lastName' => ($cookie->logged ? $cookie->customer_lastname : false), 'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order' )); return $this->display(__FILE__, 'blockuserinfo_shoo.tpl'); } 4) After in module position i put blockuserinfo to the new hook 5) After i need place {$HOOK_HEADER_DEM} to "blockcms", i do like that: <li class="shoo-myaccount">{$HOOK_HEADER_DEM}</li> After turn on compile and turn off cache i see that error: Notice: Undefined variable: HOOK_HEADER_DEM in /tools/smarty/sysplugins/smarty_internal_data.php on line 291 What i do wrong? Link to comment Share on other sites More sharing options...
bellini13 Posted June 4, 2012 Share Posted June 4, 2012 you said you changed the FrontController class, around line 500, to add the smarty variable. I assume that is in the displayHeader function where the HOOK_HEADER occurs? I would add a debug statement in the blockuserinfo module, where you added the hookheaderuserinfo function. You should first confirm that your hook is being executed. use the php error_log function to write the debug statements to a file. Link to comment Share on other sites More sharing options...
Kerm Posted June 4, 2012 Author Share Posted June 4, 2012 (edited) My FrontController.php: self::$smarty->assign(array( 'HOOK_HEADER' => Module::hookExec('header'), 'HOOK_TOP' => Module::hookExec('top'), 'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn'), 'HOOK_FOOTER_DEM' => Module::hookExec('footernewsletter'), // New Hook 'HOOK_HEADER_DEM' => Module::hookExec('headeruserinfo') // New Hook )); If i put {$HOOK_HEADER_DEM} in site template all ok, i see module, if i put in module template "blockcms.tpl" i see error... In my cms config i turn on display all erros on site, but i see only "Notice: Undefined variable: HOOK_HEADER_DEM in...." At the end of blockcms.php: public function hookTop() { global $smarty, $cookie; $cms_titles = self::getCMStitles(self::LEFT_COLUMN); $smarty->assign(array( 'block' => 1, 'cms_titles' => $cms_titles, 'theme_dir' => _PS_THEME_DIR_ )); return $this->display(__FILE__, 'blockcms_shoo.tpl'); } public function hookFooter() { global $smarty; if (Configuration::get('FOOTER_BLOCK_ACTIVATION')) { $cms_titles = self::getCMStitlesFooter(); $smarty->assign(array( 'block' => 0, 'cmslinks' => $cms_titles, 'theme_dir' => _PS_THEME_DIR_, 'display_stores_footer' => Configuration::get('PS_STORES_DISPLAY_FOOTER'), 'display_poweredby' => ((int)Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false) )); return $this->display(__FILE__, 'blockcms.tpl'); } return ''; } If i put {$HOOK_HEADER_DEM} to footer template "blockcms.tpl" its work too, but if i put in top template "blockcms_shoo.tpl" have error.. Edited June 4, 2012 by Kerm (see edit history) Link to comment Share on other sites More sharing options...
Kerm Posted June 4, 2012 Author Share Posted June 4, 2012 I think i have some error when i put blockcms in top...i just add this || !$this->registerHook('top') , and all work fine except my hook... Link to comment Share on other sites More sharing options...
Kerm Posted June 5, 2012 Author Share Posted June 5, 2012 nvm, problem resolved Link to comment Share on other sites More sharing options...
bellini13 Posted June 5, 2012 Share Posted June 5, 2012 would you explain what you changed to resolve the issue? Link to comment Share on other sites More sharing options...
infsistemas Posted June 28, 2012 Share Posted June 28, 2012 (edited) would you explain what you changed to resolve the issue? Yo lo he resuelto modificando /themes/<THEME>/category.tpl añadiendo "$category->id == 1 OR": {if $category->id == 1 OR $nb_products == 0}{l s='There are no products.'} Edited June 28, 2012 by infsistemas (see edit history) Link to comment Share on other sites More sharing options...
Kerm Posted July 1, 2012 Author Share Posted July 1, 2012 would you explain what you changed to resolve the issue? I put hook in site theme template, not found solution how put hook in module template... 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