1

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 3

3

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>');
Sign up to request clarification or add additional context in comments.

Comments

1

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

this helped me out a lot. though should be $doc->addStyleSheet($js); for adding a stylesheet
1

In Joomla! 2.5, I used the following code in the view display() :

JHtml::stylesheet(JURI::base() . 'components/com_mycomponent/css/mycomponent.css', array(), true);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.