Jump to content

Create custom Admin controller


Recommended Posts

Hello everybody,
 
I am trying to create new custom admin controller.But It gives error 'Controller not found'.
I just add one link and create a new controller in my module(MyModule/controllers/admin) folder
 
Link code is:

 
<a href='{$link->getAdminLink('AdminRecommendations')|escape:'html':'UTF-8'}&id_order={$id_order}' >
            <input type='button' class='btn btn-primary' name='recommendation' value='Recommendations'/>
        </a>

and I created controller as:

<?php
class AdminRecommendationsController extends ModuleAdminController
{
    public function __construct()
    {
        parent::__construct();

        $this->postProcess();

        die;
    }
    
    public function postProcess()
    {
        echo "Hello...";
        exit();
        parent::postProcess();
    }
}

 

But I am getting error 'Controller not found'.

 

Please help me.

 

Thanks!!!

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

  • 1 year later...

you should extends AdminController class, your class should be like this one :

class AdminmymoduleController extends AdminController
{
    public function __construct()
    {
 
        parent::__construct();
 
    }
 
    public function renderForm(){
 
         //some basics information, only used to include your own javascript
        $this->context->smarty->assign(array(
            'mymodule_controller_url' => $this->context->link->getAdminLink('Adminmymodule'),//give the url for ajax query
        ));
 
        //what do we want to add to the default template
        $more = $this->module->display($path, 'view/mymodule.tpl');
 
        return $more.parent::renderForm();//add you own information to the rendered template
    }
}
Edited by zelakioui (see edit history)
Link to comment
Share on other sites

  • 11 months later...
  • 5 years later...

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...