Search code examples
phpmodel-view-controllerprestashop-1.6

Create New Menu Tab In The Backoffice


I have some issues adding a new tab in the backoffice menu. I successfully created it with this function (called inside install method of module class):

public function createMenuTab() {
    $tab = new Tab();
    $tab->module = $this->name;
    $tab->class_name = 'AdminQuote';
    $tab->id_parent = 0;
    $tab->active = 1;
    foreach (Language::getLanguages(false) as $l)
        $tab->name[$l['id_lang']] = 'Gestione Preventivi';
    return (bool)$tab->add();
}

But now I don't know how to show a view.

I put the class AdminQuoteController in /controllers/admin/AdminQuote.php and it just extends ModuleAdminController.

What should I do now to show a view? I didn't find anything in the PS docs!


Solution

  • Finally, I find this way:

    I created the class AdminQuoteController in /controllers/admin/AdminQuote.php that extends ModuleAdminController. With this code inside:

    class AdminQuoteController extends ModuleAdminController {
        public function renderList() {
            return $this->context->smarty->fetch(_PS_MODULE_DIR_.'preventivi/views/templates/admin/content.tpl');
        }
    }
    

    This works even without declare display(), init(), initContent() or __construct() as I read in other previous threads.