Search code examples
prestashopprestashop-1.5

Prestashop ModuleAdminController use simple template


Trying to figure out why something like the below cant work. There is a tab in the preferences admin section that points to this controller but when going to it it always output a blank page. I have tried several things but the below is basically what I need. There is no MODEL... I simply need this to get the uploaded file for postProcessing...

The controller file...

class AdminAstroImporterController extends ModuleAdminController {

    public function initContent() {
        parent::initContent();
        return $this->display(__FILE__, 'import.tpl');

    }

    public function postProcess() {
        //do something here

    }
}

Solution

  • Looks like you can overide the actual content output by doing as shown in the initContent() function shown below. The 'content' in the smarty assign can be any html you generate yourself.

    class AstroImporterAdminController extends AdminController {
    public function __construct() {
        parent::__construct();
    
        //load current settings
        $this->data = unserialize(Configuration::get('ASTRO_IMPORTER'));
    }
    
    public function initContent() {
        parent::initContent();
    
        $this->show_toolbar = false;
        $this->context->smarty->assign(array(
            'content' => $this->renderSettings().$this->renderForm().$this->displayFields(),
        ));
    }