Prestashop: Extend a module template file

Created on 10 Apr 2020  路  6Comments  路  Source: PrestaShop/PrestaShop

Hello, is there a way to extend a module template file in the theme ?

Because when I try to extend
"{extends file='module:my_module/views/templates/front/view.tpl'}"
I have obviously an infinite recursive call.

we need something like :
{extends file='parent:module:my_module/views/templates/front/view.tpl'}
or
{extends file='parent_module:my_module/views/templates/front/view.tpl'}

Or another way to extends a module template without having an infinite recursive loop.

Thank you.

1.7.0.0 BO Developer Feature FO Feature TBS

Most helpful comment

It looks like this is a real issue. It's possible to _override_ a complete module template, but not to _extend_ it.

According to the documentation, you can override any module template just by redefining it in the theme by convention. But you cannot _extend_ it, because in order to extend it you need to use {extends file='module:my_module/views/templates/front/view.tpl'}, and since the module: namespace will reference the file from the theme instead of the module's, this will result in an infinite loop.

We'd need a special namespace like parent:module or something like that.

All 6 comments

Thanks for opening this issue! We will help you to keep its state consistent

Hello,

Please be aware that this bug tracker should be used to report issues only.
If you need help, you can ask on the :

  • Forum (https://www.prestashop.com/forums/)
  • Gitter (https://gitter.im/PrestaShop/General)
  • Stack Overflow (https://stackoverflow.com/questions/tagged/prestashop)

Thanks for your understanding!

It looks like this is a real issue. It's possible to _override_ a complete module template, but not to _extend_ it.

According to the documentation, you can override any module template just by redefining it in the theme by convention. But you cannot _extend_ it, because in order to extend it you need to use {extends file='module:my_module/views/templates/front/view.tpl'}, and since the module: namespace will reference the file from the theme instead of the module's, this will result in an infinite loop.

We'd need a special namespace like parent:module or something like that.

We definitively need this, thanks. We have infinite loops too.

Currently, the only way to avoid infinite loop is to use {extends file='modules/MODULE_NAME/...'} in your theme. I agree with @eternoendless, it would be better to have special namespace like parent: for child themes.

Was this page helpful?
0 / 5 - 0 ratings