Jump to content

Connecting module with controller


piotr.petrasz

Recommended Posts

Hi Everyone,

 

I have a simple question associated with creating modules.... 

 

Tutorial on PrestaShop website and other infos available on the Internet have a one method to create module and connect them with controller eg. XXX extends ModuleFrontController - by create a link from displayed template to another template which is called by setTemplate... 

 

my question is how to connect the first template, called from modules/mymodule.php  clause:

 

 public function hookdisplayHome($params)
    {
     return $this->display(__FILE__, 'furniturefind_form.tpl');
    }

 

I would like to have furniturefind_formFrontModuleController extends ModuleFrontController connected with this template. 

 

Thanks in advance for your attention and help,

 

Peter 

Link to comment
Share on other sites

Hi,

 

thank you for your answer. 

 

I have module controller located in modules directory. 

 

I`ve created a new module (FurnitureFind) with main file furniturefind.php which contains base classe furniturefind extends Module. And then in:

public function hookdisplayHome($params)
    {
     return $this->display(__FILE__, 'furniturefind_form.tpl');
    }
i would like to present this tpl in home page. This tpl contains my form (3 buttons). To handle to action for this buttons I need to have FrontController conected with this template, and I don`t know how to do it. 
 
As an attachement you can find my module directory. 
 
Regards,
Peter 

furniturefind.zip

Link to comment
Share on other sites

hi..

if you have display front tpl then you can register the hook of your modules install method.
 

public function install()
{
 if (Shop::isFeatureActive())
Shop::setContext(Shop::CONTEXT_ALL);


 return parent::install() &&
$this->registerHook('home') &&
$this->registerHook('header') &&
Configuration::updateValue('FurnitureFind', '');
 }
  

and display the modules tpl file thios way

 

public function hookdisplayHome($params)
{
return $this->display(__FILE__, 'furniturefind_form.tpl');


}

above hook home and uts display your tpl file

thanks.

Edited by Nishith (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...