I currently works on a custom module who add features to the Prestashop native store locator.
For my needs, i must create a second custom page in my module (and a second controller).
I tried something but nothing works.
I override FrontController file in my directory -> /module/override/controllers/front/StorepageController.php
<?php
class StorepageController extends FrontController
{
public function initContent()
{
parent::initContent();
$this->setTemplate(_PS_MODULE_DIR_.'modulename/views/templates/front/storepage.tpl');
}
And i put my .tpl file in this directory -> /module/views/templates/front/storepage.tpl
And to finish, i erase "class_index.php" and i try to see my page with this link :
localhost/prestashop/fr/index.php?controller=storepage
I don't understand why nothing is working.
Here we will create a new Controller called
myStore
in a module calledCustomStores
. We will take into account that you already overrided the defaultStoresController.php
.Your module looks like this:
Now you want to had a new controller, it's not an override. we will create this new Controller by extending the
ModuleFrontController
.Your module tree will now look like this:
Following is
mystore.php
code:I've also added a custom class for you module called
CustomStore.php
, here we go for the code:You will have to create the
customstores_store
table inside your moduleinstall()
method:This code was not tested and was written in a single shot, but all the concept you will need are here ;). I advise you to look at other core modules code if you want to learn more. Have fun !