Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have created a custom module that creates a page with the path /mymodule

Now I what to create a template for that page and also add a .css file and a .js file that loads only when my page shows.

I don't seem to be getting anywhere searching online.

Any direction here would be creatly appreciated.

C

share|improve this question
add comment (requires an account with 50 reputation)

2 Answers

You should use drupal_add_css() and drupal_add_js()

check this on api add js enter link description here and add cssenter link description here

share|improve this answer
Thanks @crazyrohila but it's more about the funtion that calls those functions. I only want the drupal_add_css() and drupal_add_js() to add those files when my templte is being used, not on every page and not called in the template.php file with if(arg(0) == 'path') – cybercampbell Apr 5 at 12:03
add comment (requires an account with 50 reputation)

You can define a custom content type for the page that your custom module created, then add a template for that content type and add your module's css and js on that page. More info...

share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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