Add Link to Javascript Files In Admin Head Area Of Template

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
jeverd01
Forum Members
Forum Members
Posts: 20
Joined: Thu May 20, 2010 2:00 am

Add Link to Javascript Files In Admin Head Area Of Template

Post by jeverd01 »

I've searched the form and can't seem to find a simple solution. I want to add a link to a static JavaScript file that my module will use to the header of the admin section, basically so I can call datepicker since I see jquery-ui is already included in the admin theme.

Is there any easy way to load specific JS files on certain admin tabs?
jeverd01
Forum Members
Forum Members
Posts: 20
Joined: Thu May 20, 2010 2:00 am

Re: Add Link to Javascript Files In Admin Head Area Of Templ

Post by jeverd01 »

I guess putting jquery in the body of the document and using document.ready works. It's not the best practice but it works.
User avatar
kidcardboard
Forum Members
Forum Members
Posts: 54
Joined: Mon Sep 28, 2009 5:25 pm

Re: Add Link to Javascript Files In Admin Head Area Of Templ

Post by kidcardboard »

Put this in your <modulename>.module.php file

Code: Select all

function GetHeaderHTML() {
    global $gCms;
    $config = $gCms->GetConfig();
    return "\r<script type='text/javascript' src='".$config['root_url']."/modules/<modulename>/lib/script.js'></__script>";
}
Post Reply

Return to “Developers Discussion”