Actions

J3.x talk

Adding JavaScript and CSS to the page

From Joomla! Documentation

Revision as of 17:52, 11 March 2009 by Bembelimen (Talk | contribs)

Hello there.. I was about to pitch in and add on a whole other section on basically doing the exact same thing you did with $document.. except using the JHTML class. I wasn't exactly sure why you'd use one over the other and thought I'd ask if you knew why this redunacy exists and if one is in some way more helpful. Any ideas? Haelix 23:45, 8 November 2008 (EST)

Haelix, I agree. It appears that the JHTML classes wrap the $document methods, and take care of anything else you might need (like mootools). I have updated the article to reflect this.Mike 21:24, 17 February 2009 (UTC)

what page should we keep ? this one http://docs.joomla.org/Adding_JavaScript or this one http://docs.joomla.org/Adding_JavaScript_and_CSS_to_the_page ?


Using the class loader method is the common way:

JHTML::_('script', $filename, $path);
JHTML::_('stylesheet', $filename, $path);

Bembelimen