tozi Posted June 3, 2014 Share Posted June 3, 2014 Hi all, it is possible filtering like in screen? I tried create hook and hook him. public function hookdisplayTop3() { if(!$this->_prepareHook()) return; // Check if not a mobile theme if ($this->context->getMobileDevice() != false) return false; } But doesnt work. Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 Hi. Yes, it is possible. But to make it work you need to add a new hook and also execute it. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted June 3, 2014 Author Share Posted June 3, 2014 1. i create a hook (in db and frontcontroler) 2. in module i insert this public function hookdisplayTop3() { if(!$this->_prepareHook()) return; // Check if not a mobile theme if ($this->context->getMobileDevice() != false) return false; } 3. i insert this code for show module in category.tpl <div class="layered">{$HOOK_TOP3}</div> But doesnt work. I have a blank page. and this Fatal error: Call to undefined method BlockLayered::_prepareHook() in /home/www/sirer.cz/www/sirer.cz/bike/modules/blocklayered/blocklayered.php on line 55 Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 (edited) It means the module has no '_prepareHook()' function. You need to create it. Regards.Robin.The CartExpert Team Edited June 3, 2014 by CartExpert.net (see edit history) Link to comment Share on other sites More sharing options...
tozi Posted June 3, 2014 Author Share Posted June 3, 2014 (edited) Thanks. I reinstall module and in module i insert this public function hookdisplayTop3() { // Check if not a mobile theme if ($this->context->getMobileDevice() != false) return false; } Nothing happend. Problem is still there. edit: so i need create it like this? class/controller/FrontController.php if (!isset($this->context->cart)) $this->context->cart = new Cart(); $this->context->smarty->assign(array( 'HOOK_HEADER' => Hook::exec('displayHeader'), 'HOOK_TOP' => Hook::exec('displayTop'), 'HOOK_TOP2' => Hook::exec('displayTop2'), 'HOOK_TOP3' => Hook::exec('displayTop3'), 'HOOK_prepare' => Hook::exec('_prepareHook'), Edited June 3, 2014 by tozi (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 Nothing happens for hookdisplayTop3 because you don't return anything, so nothing to display. What is this for: 'HOOK_prepare' => Hook::exec('_prepareHook'), The fatal error you had meant that the module doesn't have the '_prepareHook' function. That function needs to be inside the module, not as a hook. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted June 3, 2014 Author Share Posted June 3, 2014 Now I am totally confused. This module has a different function that can be used? Or what is needed to view this module in a Hook? Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 (edited) First of all, decide where you want the module to be displayed. If there is no hook there you create one. Let's call it myTestHook. You add myTestHook to the database. Then you need to execute the hook in the controller. e.g. the FrontController Hook::exec('myTestHook') The function for this has to be created in the module, so you will have a function named 'hookMyTestHook', which can have a return value, or not. In your case, you want a return value, because you want to display the layered filter. Hook::exec('myTestHook') must be assigned to the template, just like Hook::exec('leftColumn') is. Now you need to place {$HOOK_MY_TEST_HOOK} in the tpl file where you want the module to be displayed. Finally, you need to transplant your module to the hook. You can just duplicate the hookLeftColumn function of the module, rename it to match the new hook's name, instead of creating new a function from scratch. But for this you must have a basic concept of coding, like functions returning value, OOP etc. Regards.Robin.The CartExpert Team Edited June 3, 2014 by CartExpert.net (see edit history) Link to comment Share on other sites More sharing options...
tozi Posted June 3, 2014 Author Share Posted June 3, 2014 All i have, without function in module. How can i create this function? Again i need only display this module in category.tpl or product-list.tpl Help anyone? Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 You can just duplicate the hookLeftColumn function of the blocklayered.php, rename it to match the new hook's name. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted June 3, 2014 Author Share Posted June 3, 2014 I did it but still not working. I copy function and rename public function hookdisplayTop3($params) { return $this->generateFiltersBlock($this->getSelectedFilters()); } And insert this before install public function hookdisplayTop3() { return $this->hookLeftColumn(); } Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 (edited) Use: public function hookDisplayTop3($params) { return $this->hookLeftColumn($params); } Did you transplant the module to the displayTop3 hook? Did you call the Hook's exec function in FrontController.php ? Regards.Robin.The CartExpert Team Edited June 3, 2014 by CartExpert.net (see edit history) Link to comment Share on other sites More sharing options...
tozi Posted June 4, 2014 Author Share Posted June 4, 2014 Result is this [PrestaShop] Fatal error in module Module.php(1080) : eval()'d :Cannot redeclare BlockLayered::hookdisplayTop3() Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 4, 2014 Share Posted June 4, 2014 It means the hookdisplayTop3() is declared twice: you have this function twice. Remove the one that's not good. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
tozi Posted June 4, 2014 Author Share Posted June 4, 2014 I remove but no effect. Already dont know what to try. Here is my blocklayered.php http://uloz.to/xeGFiPNX/blocklayered-zip 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