Jump to content

Views override from overriden controller in 1.509


Recommended Posts

Hi Prestashop Team!

 

I'm working on a module that uses controllers overriding. While installing it copies several overriding files to override/controllers/... and deletes them while uninstalling.

But I have a problem when try to override view.tpl from this overriden controller.

 

When I'm working with my own controller which is an instance ModuleAdminController all is ok - I set override_folder for HelperView and place all needed tpl's in my module folder (in the correct folder tree).

 

But I can't set override folder for view.tpl correctly for my overriden controller.

 

 if ($this->override_folder)
 {
  if ($this->context->controller instanceof ModuleAdminController)
$override_tpl_path = $this->context->controller->getTemplatePath().$this->override_folder.$this->base_folder.$tpl_name;
  else if ($this->module)
$override_tpl_path = _PS_MODULE_DIR_.$this->module->name.'/views/templates/admin/_configure/'.$this->override_folder.$this->base_folder.$tpl_name;
  else
$override_tpl_path = $this->context->smarty->getTemplateDir(0).'controllers/'.$this->override_folder.$this->base_folder.$tpl_name;
 }

 

Because in the final function Helper->CreateTemplate my controller gets into the last else branch of the code above where $this->context->smarty->getTemplateDir(0) returns the path to the current admin theme. I need to call view.tpl which will be placed in my module folder from the controller placed in override/controllers folder.

 

How can I do this without overriding CreateTemplate of Helper class?

Thanks.

Link to comment
Share on other sites

  • 1 year later...

hi absolutic, have you tried to get template directly from the smarty variable with the:

$this->context->smarty->createTemplate(path to template folder, $this->context->smarty);

 

in the path to template folder, i can suggest you to start with the directory of the controller, dirname(__FILE__) and get back to template directory

  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...