Add Css and Javascript inside Joomla Component

Hi Friends,

I you want to include external css andjavascript in your Joomla component then you can use following code.


<?php

$document = JFactory::getDocument();

//  For javascript or jquery file
$document->addScript('components/component_name/assets/js/jquery.js');  

// For include css file
$document->addStyleSheet('components/component_name/assets/css/screen.css'); 

?>

If you want to include images in  your component the you can use following code

<img src="<?php echo JURI::root();?> path">
i.e.
<img src="<?php echo JURI::root();?>components/component_name/images/images1.png">
Advertisements
Categories: Joomla | Tags: , , , , , , | 3 Comments

Post navigation

3 thoughts on “Add Css and Javascript inside Joomla Component

  1. I every time emailed this web site post page to all my contacts, because if like to read it then my links will too.

  2. Good post! We aree linking to this particularly great article on our website.
    Keep up the great writing.

  3. Magnificent beat ! I wish to apprentice whilst you amend your web
    site, how can i subscribe for a blog web site?The accoun helped me a appropriate deal.

    I were tiny bit familiar of this your broadcast provided brilliant clear concept

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: