Jump to content

Override Of Admin Controller By A Module :


Recommended Posts

Hi, I'm currently on a module that will add fields in the AdminOrdersController.php located here :

/controller/admin/AdminOrdersController.php

So I put the override in my module here :

my_module/override/controllers/admin/AdminOrdersController.php
<?php

class AdminOrdersController extends AdminOrdersControllerCore
{
    public function postProcess()
    {
       parent::postProcess();
    }
    public function renderView()
    {
      parent::renderView();
    }
}

And I wanted to override the _shipping.tpl located here :

/gestion/themes/default/template/controllers/orders/_shipping.tpl

So I put in my module a file named _shipping.tpl here :

my_module/override/controllers/admin/templates/orders/_shipping.tpl

And nothing happen.

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

_shipping.tpl is not loaded by the controller framework, which means you cannot override it directly.  It is included by a different admin theme file, which is...

admin\themes\default\template\controllers\orders\helpers\view\view.tpl

so you have to override both view.tpl and _shipping.tpl.  In view.tpl you will find ...

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

so in your override view.tpl, you would change it to ...

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

A few notes...

1) You don't have to override the AdminOrder controller for this. 

2) The admin themes make use of module hooks, so it is always best to try to use a module hook before you resort to using overrides.  So if you are trying to add something to these section, then you may want to use the '$HOOK_CONTENT_SHIP' hook that is defined in _shipping.tpl

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...