vasikgreif Posted June 25, 2010 Share Posted June 25, 2010 Hi everybody, I'm new to Presta and trying to understand the template basics. I would need to move search module. I made new hook - menu - I added it in database, in header.php I added 'HOOK_MENU' => Module::hookExec('menu'), in header.tpl I added {$HOOK_MENU} but I don't understand what to edit in blocksearch.php to display the search module in the new menu hook. Bloacksearch.php is now: <?php class BlockSearch extends Module { function __construct() { $this->name = 'blocksearch'; $this->tab = 'Blocks'; $this->version = 1.0; parent::__construct(); $this->displayName = $this->l('Quick Search block'); $this->description = $this->l('Adds a block with a quick search field'); } function install() { if (!parent::install() OR !$this->registerHook('top') OR !$this->registerHook('header')) return false; return true; } function hookLeftColumn($params) { global $smarty; $smarty->assign('ENT_QUOTES', ENT_QUOTES); $smarty->assign('search_ssl', (int)(isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')); // check if library javascript load in header hook $this->_disabledSearchAjax(); $smarty->assign('ajaxsearch', intval(Configuration::get('PS_SEARCH_AJAX'))); return $this->display(__FILE__, 'blocksearch.tpl'); } function hookRightColumn($params) { global $smarty; $smarty->assign('ENT_QUOTES', ENT_QUOTES); $smarty->assign('search_ssl', (int)(isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')); // check if library javascript load in header hook $this->_disabledSearchAjax(); $smarty->assign('ajaxsearch', intval(Configuration::get('PS_SEARCH_AJAX'))); return $this->display(__FILE__, 'blocksearch.tpl'); } function hookTop($params) { global $smarty; $smarty->assign('ENT_QUOTES', ENT_QUOTES); $smarty->assign('search_ssl', (int)(isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')); // check if library javascript load in header hook $this->_disabledSearchAjax(); $smarty->assign('ajaxsearch', intval(Configuration::get('PS_SEARCH_AJAX'))); return $this->display(__FILE__, 'blocksearch-top.tpl'); } function hookHeader($params) { if (Configuration::get('PS_SEARCH_AJAX')) return $this->display(__FILE__, 'header.tpl'); } private function _disabledSearchAjax() { if (!$this->isRegisteredInHook('header')) Configuration::updateValue('PS_SEARCH_AJAX', 0); } } Could some of the elders help me? Thanks Link to comment Share on other sites More sharing options...
razaro Posted June 25, 2010 Share Posted June 25, 2010 Check this tutorial http://ardianys.com/64_how-to-add-new-hook-prestashop-engine-modification-tutorial-series.htmlit should help you.You need function hookMenu($params) { global $smarty; $smarty->assign('ENT_QUOTES', ENT_QUOTES); $smarty->assign('ajaxsearch', intval(Configuration::get('PS_SEARCH_AJAX'))); return $this->display(__FILE__, 'blocksearch-top.tpl'); } and also check other steps. Link to comment Share on other sites More sharing options...
vasikgreif Posted June 25, 2010 Author Share Posted June 25, 2010 Thanks, helped me a lot, works like a charm! Link to comment Share on other sites More sharing options...
rocky Posted June 26, 2010 Share Posted June 26, 2010 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
HiFriend Posted June 27, 2010 Share Posted June 27, 2010 Actually,I encountered the same problem with vasikgreif, and I read carefully of the tutorial , but still confused about the 4th step:#4 Make your module executed with this hookWhat exactly should I do to modify code in this part, especially for modules other than the search one, for example, addstuff module;Is there any universal solution?I think this is a great concern of many people, anyone could help??thx a lot!Woody Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 You should create a new function called "hook" followed by the name of the hook you created in the module's PHP file, like in razaro's reply above. In that function, you can write any code you want and call a Smarty template, or you can simply call another hook using code like the following: function hookRightColumn($params) { return $this->hookLeftColumn($params); } This column will put the same code in the right column as the left column. Link to comment Share on other sites More sharing options...
HiFriend Posted June 27, 2010 Share Posted June 27, 2010 it wroks fabulously;One last question: why do I need to modify the function of install?"Change your install function into:view sourceprint?17 function install()18 {19 if (!parent::install() OR !$this->registerHook('center') OR !$this->registerHook('header'))20 return false;21 return true;22 }"Should I replace the counterpart with the above code in the php file everytime I hook up a new module?thxWoody Link to comment Share on other sites More sharing options...
rocky Posted June 27, 2010 Share Posted June 27, 2010 You only need to modify the install function if you want the module to be installed into the hook you created by default when the "Install" button is clicked next to the module. Unless you're planning to release your modified module publicly, it is unnecessary. Link to comment Share on other sites More sharing options...
HiFriend Posted June 27, 2010 Share Posted June 27, 2010 Thanks again for your timely explanation, I really appreciate 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