StejkEU Posted August 11, 2016 Share Posted August 11, 2016 Hello, i trying to make buttons in my custom AdminController. I successfully created page from my .tpl file, now i need add two buttons. First will start one method and another too. Please Help me with this. Here is my code: <?php class AdminMojeDPDController extends ModuleAdminController { public function __construct() { $this->className = 'AdminMojeDPD'; $this->lang = true; $this->deleted = false; $this->colorOnBackground = false; $this->context = Context::getContext(); parent::__construct(); } public function getTemplatePath() { return _PS_MODULE_DIR_.$this->module->name.'/views/templates/admin/'; } public function createTemplate($tpl_name) { if (file_exists($this->getTemplatePath() . $tpl_name) && $this->viewAccess()) return $this->context->smarty->createTemplate($this->getTemplatePath() . $tpl_name, $this->context->smarty); return parent::createTemplate($tpl_name); } public function initContent(){ $page = $this->createTemplate('operations.tpl'); $this->content = $page->fetch(); //$this->module->closeManifest(); parent::initContent(); } } Link to comment Share on other sites More sharing options...
orioltestart Posted August 11, 2016 Share Posted August 11, 2016 I really don't know how to do it in the proper way, actually I have the same doubt. I guess that you could add the buttons in the template directly (or create the whole form with an action). I guess the best option would be creating the form with the FormHelper but I don't know how to render it in the desired place and with the desired handler. Then begins my doubts, the action must be handled by the module.php or by the controller? Its as simple of creating an postProcess() method? Where should I put that? Controller/Module And the renderForm() method when it's called? I have to assign the result on the $smarty variable? But if so, I have to put the renderForm in the Controller, it will work? Sorry for that many questions, I don't want to steal your thread. Hope someone could help us! Thanks! Link to comment Share on other sites More sharing options...
StejkEU Posted August 11, 2016 Author Share Posted August 11, 2016 Okey, i barely solve this. Who needs buttons? Just links with style of buttons. <?php class AdminMojeDPDController extends ModuleAdminController { public function __construct() { $this->className = 'AdminMojeDPD'; $this->lang = true; $this->deleted = false; $this->colorOnBackground = false; $this->context = Context::getContext(); $this->bootstrap = true; if(isset($_GET['action'])){ switch ($_GET['action']) { case 'closeManifest': die("closeManifest"); break; case 'pickup': die("pickup"); break; } } parent::__construct(); } public function getTemplatePath() { return _PS_MODULE_DIR_.$this->module->name.'/views/templates/admin/'; } public function createTemplate($tpl_name) { if (file_exists($this->getTemplatePath().$tpl_name) && $this->viewAccess()) { return $this->context->smarty->createTemplate($this->getTemplatePath().$tpl_name, $this->context->smarty); } return parent::createTemplate($tpl_name); } public function initContent() { $token=Tools::getAdminToken($this->className.intval(Tab::getIdFromClassName($this->className)).intval($this->context->cookie->id_employee)); $page = $this->createTemplate('operations.tpl'); $this->context->smarty->assign("manifest", "index.php?controller=".$this->className."&action=closeManifest&token=".$token); $this->context->smarty->assign("pickup", "index.php?controller=".$this->className."&action=pickup&token=".$token); $this->content = $page->fetch(); parent::initContent(); } } And template <a href="{$manifest}" class="btn btn-lg btn-success">Print labels</a> <a href="{$pickup}" class="btn btn-lg btn-primary">Pickup</a> 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