Based on the idea of a module for doing this which I found in a PrestaShop 1.5 article, I did the following...
- Use the PrestaShop module generator to create a new module
- Inside the module folder, create folders /controllers/front/
- Inside /controllers/front/, create a php file that describes the action for the controller
- Name the controller class {modulename}{action}ModuleFrontController (extends ModuleFrontController). E.g. module changepassword, controller file changepassword.php would be
class changepasswordchangepasswordModuleFrontController extends ModuleFrontController - I BELIEVE case is unimportant, but make it case sensitive just in case.
- If the customer needs to be logged in to use the action, then set the following at the beginning of the class before adding functions to your ModuleFrontController
public $auth = true; - Put your template in /modules/{your_module}/views/templates/front/{your_template_name}.tpl
- In your ModuleFrontController::initContent() function, do
parent::initContent(); $this->setTemplate('{your_template_name}.tpl'); - If you are submitting to self, you form action (in the tpl file) should be
action="{$link->getModuleLink('{modulename}', '{action}')|escape:'html':'UTF-8'}" - If you need to define smarty values based on the submitted form, use $this->context->smarty->assign in the init function of your ModuleFrontController.
- Define a URL for the form in admin area -> preferences -> SEO & URLs.
No comments:
Post a Comment