Jump to content

Put js script content into head


Recommended Posts

Hello.

 

I'am working on my own module.

 

I want to put content of my js script into head.

 

I've created hook hookDisplayHeader().

There i put another method which calls:

 

$this->context->controller->addCSS();

$this->context->controller->addJS();

 

Next i'am putting between addCSS() and addJS(): $this->smarty->assign('returning value form method') and $this->display(__FILE__, 'myTPLfile.tpl') which contain:

 

<script type="text/javascript">
    var data = {$returning value form method};
</script>

 

Everythink goes good, CSS and JS (calling from context) are adding correct, but this js script in tpl file is putting on the top of the site, before <html>.

 

How can i put it into <head> that returned my js script? I want it after addCSS and before addJS.

 

If it is in bad section please move it to another. :)

Edited by Szpadyzor (see edit history)
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...