Jump to content

How to overloading / overriding an existing back-office template


Soufyan Amenzou

Recommended Posts

Hi everybody,

 

I would like to overloading or override a back-office template.

 

The template is this one : admin170/themes/template/controllers/products/prices.tpl

 

In my modules I put my tpl file in thhis location => my_module/override/controllers/admin/templates/products/prices.tpl

To test my tpl file, I put only few code

[/font][/color]
[color=#000080][font=verdana, geneva, sans-serif][/font][/color]
[color=#000080][font=verdana, geneva, sans-serif]{extends file="products/prices.tpl"}

{block name="after"}
<p style="color:red;text-align:center;">Block after : add a text after the form</p>
{/block}

 

I saw this example in confluence documentation prestashop 1.5 => http://doc.prestasho...office+template

But I got nothing even if I uninstall and reinstall my module

 

For information I managed to override the AdminProductsController.php.

How ? In my module I create file in this location => my_module/override/controllers/admin/AdminProductsController.php which extend AdminProductsControllerCore

 

Now I'm trying to override a tpl file.

 

I hope my topic is clear,

Best regards.

 

Soufyan

Edited by soufyan (see edit history)
Link to comment
Share on other sites

Hello,

 

You should uninstall and reinstall your module again, because prestashop copies everything, located in moduleName/override folder into prestashop/override. So ultimately your prices.tpl file must be placed in prestashop/override/controllers/admin/templates/products.

 

 

UPD

Sorry, but my first post was little bit misleading. Prestashop copies only php files located in moduleName/override. So you should have put your prices.tpl right into prestashop/override/controllers/admin/templates/products and not into your module's override folder.

Edited by daur88 (see edit history)
Link to comment
Share on other sites

daur88: your answer is quite right, but just to develop your module so that chnages can take effect immediatly.

 

But when you then have to install the module, the tpl-files should also be copied to the right place, and this is where the problem is.

 

Hope for changes from Prestashop team.

  • Like 1
Link to comment
Share on other sites

Hello I'm trying to override prestashop15\site-admin\themes\default\template\controllers\orders\_customized_data.tpl

 

and I have copied it into this path:

prestashop15\override\controllers\admin\templates\orders\_customized_data.tpl

 

but I can't see any changes, could please tell me the right way to do this?

Link to comment
Share on other sites

  • 1 month later...

You are right, I have the same problem with tpl begining with _. So I'm digging a little and those templates are included in another parent tpl. In the case of _customized_data.tpl is the orders/helpers/view/view.tpl

 

I think you must override view.tpl and then change in some way

{include file='controllers/orders/_customized_data.tpl'}

 

 

Edit: It'worked for me. But i had to put _customized_data.tpl in the same folder of view.tpl and use

{include file='./_customized_data.tpl'}

 

capturagm.jpg

Edited by egomezpe (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 10 months later...
  • 1 month later...
  • 11 months later...
  • 6 months later...

I copied the files view.tpl and _product_line.tpl, changed the path as described above in view.tpl.

It works, but to make things nicer I had to implement this method in my module:

    private function installCustomTemplates()
    {

        $this->custom_templates = array(
            'override/controllers/admin/templates/orders/helpers/view/view.tpl',
            'override/controllers/admin/templates/orders/helpers/view/_product_line.tpl',
        );

        $success = true;
        foreach ($this->custom_templates as $ct) {
            $destination = _PS_ROOT_DIR_.'/'.$ct;
            $custom_template = $this->local_path.$ct;

            // @TODO: this should be improved by adding ability to report errors
            if (!Tools::file_exists_cache($destination) && Tools::file_exists_cache($custom_template)) {
                $template_directory = dirname($destination);
                if (!Tools::file_exists_no_cache($template_directory)) {
                    $success = $success && @mkdir($template_directory, 0755, true);
                }
                $success = $success && @copy($custom_template, $destination);

                do {
                    if (Tools::file_exists_cache(_PS_ROOT_DIR_.'/config/index.php') && !Tools::file_exists_cache($template_directory.'/index.php')) {
                        $success = $success && @copy(_PS_ROOT_DIR_.'/config/index.php', $template_directory.'/index.php');
                    }
                    $template_directory = dirname($template_directory);

                } while (strlen(_PS_ROOT_DIR_) < strlen($template_directory));

            }
        }
        return $success;
    }
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...