I am very new to Expression Engine .

I have created a module , i want to know how do i load/run it in the current template .

I want to add some custom javascript to the front end website , and i know that i have to use

$this->EE->cp->add_to_head('myscript'); or any other function

But i don't know where should i call this function . I tried to call it in the mod.my_module.php in construct function but nothing happened.

Is there something i am missing ?


2 Answers 2


Take a look at the answer I gave here, and specifically this bit:

If you want to output the JS file URL in your templates, create a method in your mod file that outputs URL_THIRD_THEMES.'your_addon/js/file.js' or something like that. Then use {exp:your_addon:your_method} to output the URL in the template.

Using $this->EE->cp->add_to_head() only applies to Control Panel pages.

  • ok , thanks for the answer . i think now i am understanding how EE works .
    – adi rohan
    Apr 22, 2013 at 15:54

You could also take a look a at my Theme Loader class, which does some extra things and makes code a little easier to manage for older versions of EE and various configurations.


Not the answer you're looking for? Browse other questions tagged or ask your own question.