Jump to content

Override admin_order.js ps 1.6.0.5


Recommended Posts

Hello,

 

I have searched for a while to find the answer of my quetsion but with no luck. Therefor I now turn to you.

 

First question:

 

I am creating a custom module that is hooked to AdminOrder in PS 1.6.0.5. I have created a custom hook at the bottom of view.tpl and now I want to use javascript/jquery. My question is how I can override the js-file admin_order.js in my module or more exact, where do I put the file "path-wise"? Have tried putting it in here: /ps_root/modules/my_module/override/js but with no luck.

 

Second question:

How to add a custom hook into a tpl when installing a custom module? What I want is to add a hook to the bottom of view.tpl (/ps_root/admin/themes/default/template/controllers/orders/helpers/view) when installing my module.

 

Thanks in advance!

Link to comment
Share on other sites

Override javascript

You just have to place your js file after admin_order.js (hook displayBackOfficeHeader)

<script type="text/javascript" src="/admin/js/admin_order.js"></script>
<script type="text/javascript" src="PATH_TO_YOUR_MODULE/js/override_admin_order.js"></script>

So if admin_order.js contains

function displayMyAlert() {
    alert('Hello world');
}

$(document).ready(function(){
    $('#testAlert').click(function(){
          displayMyAlert();
    });
});

And then your override_admin_order.js contains

function displayMyAlert {
    alert('Overridden Text');
}

When you click a HTML tag with attribute id="testAlert", the alert text displayed on browser should be "Overridden Text" instead "Hello world"

 

 

Adding custom hook

 

In your module file define a function for your custom hook, and this function return to the available Prestashop hook where your programing script defined.

public function hookDisplaybackOfficeTop($params)
{
    // YOUR PROGRAMING CODE HERE

    return $this->display(__FILE__, 'my_module.tpl');
}

public function hookDisplayMyCustomHook($params)
{
    return $this->displayBackOfficeTop($params);
}

And then in your smarty file you can use smarty hook. (override admin theme file view.tpl)

{hook h="displayMyCustomHook"}
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

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