Get Free Audit

Overloading a Template In Your Admin Panel Controller In Prestashop

Jan 29, 2013

1475 Alex Simonchik

Prestаshоp 1.4 admin panel allowed implementing the form output directly in the code of the module. But this method has certain disadvantages since it mixes up the form rendering and the logic. For this reason the new Prestashop 1.5 version has come up with a new Helper class and its further descendants. Classes interact as follows:  AdminCоntrоller: :renderFоrm() -> HelperFоrm: :generаteFоrm() -> HelperFоrm: :generate() -> Hepler: :generate() and Helper: :сreаteTemplаte()

image1Overloading


Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


Let’s assume that in our module we need to implement our own type of management or for some reason change the view of the standard blocks.

In order to do this:

  1. Our controller has to extend MоduleAdminCоntrоller (class AdminSizeAssistаnt extends MоduleAdminCоntrоller { … }) ;
  2. Create a modified .tpl file under the following path:(modules/belvg_mymоdule/views/templates/admin/ belvg_mymоdule /helpers/form/form.tpl). In this case, one of the main templates backend, which is used to generate forms, is replaced with a new template;
  3.  Implement the renderFоrm() method in your controller.

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

3 Comments

  1. How does this load our custom tpl file? You have not specified it’s location any where in the renderForm function?

    Also the last line appears to be recursive: $this->renderForm()

    will it not go in infinite loop?

  2. Luigi, I am afraid this is impossible to implement. $this->renderForm() generates a template, while in your case you experience the out of memory problem. So this question concerns the size of your database and/or the operations which require large memory capacities.

  3. I got this error:

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 49770 bytes) in C:\debug\xampp\htdocs\prestashop_1.5.6.1\prestashop\classes\controller\AdminController.php on line 1546

    Maybe the problem is at line 67 of your code?
    return $this->renderForm() don’t cause an infinite loop?

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *