I want to insert .js files & css files into my joomla component,and call all these files in a .php file.Is anybody know whats the procedure for this. Thanks
3 Answers
Happen to be working on this right now.
In file \com_yourcomponent\views\yourview\view.html.php, within function display(),
$document->addStyleSheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css');
$document->addCustomTag('<script type="text/javascript" src="components/com_yourcomponent/js/jquery-1.7.2.min.js"></script>');
Comments
in your components use :
$js = JUri::root() . 'mycssFolder/style.css';
$doc = JFactory::getDocument();
$doc->addScript($js);
for more info http://docs.joomla.org/JDocument/addScript
1 Comment
suo
this helped me out a lot. though should be
$doc->addStyleSheet($js); for adding a stylesheet