Jump to content

How to create custom views for a module's backend controller?


Recommended Posts

Hi. I'm doing a module for PS 1.6.1.5  and after reading a lot of topics I'm getting  a bit lost about the explanations to do customized backend pages. Default method (getContent()) works fine, but i want to do 2 or 3 pages for employees so there are needed a couple of controllers.

I have created successfully a menu item linking to a new controller and it gets executed.

First thing I don't fully understand is the difference between AdminController and ModuleAdminController.

Second thing I need is to show a custom tpl file for this controller. 

class AdminMyCustomControllerController extends ModuleAdminController { //located at mymodule/controllers/admin/AdminMyCustomControllerController.php
public function __construct() {

        $this->name = 'mycustomcontroller';
        $this->version = '1.0.0';
        $this->bootstrap = true;
        $this->table = 'example'; //for now not using objectModel to save data
        $this->className = 'AdminMyCustomController';
        parent::__construct();
}


public function initContent() {
        parent::initContent();
        $smarty = $this->context->smarty;
        $smarty->assign('test', 'test1');        
        $this->setTemplate('mytemplate.tpl');//located at mymodule/views/templates/admin/mytemplate.tpl
    }
 
Debugging until a SmartyException (blank page shown):
"Unable to load template file 'C:\htdocs\rootFolder\adminblablabla/themes/default\template\mytemplate.tpl'"
Why it is looking for it at admin and not in myModule's?
Thank you.
Link to comment
Share on other sites

Hi!!!

 

Try to put your tpl inside your theme:

 

themes/yourtheme/modules/yourmodule/views/templates/admin/yourtpl.tpl

 

and get the content

 

$template = $this->createTemplate("yourtpl.tpl");
$template->assign(array(
"varprueba" => "hi!!"
));
$page = $template->fetch();
 
return the $page in your renderView, renderForm or any method that you use.
 
it works for me
Link to comment
Share on other sites

  • 1 month 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...