How to add external libraries in joomla 3.8?

210 Views Asked by At

I need to include in my joomla project some external libraries but I don't understand how to do this.

However, I find that is necessary create a directory com_mycomponent and inside enter all files/folders js and css.

Ok, I do this but.. where I should tell joomla where they are?... I know that is necessary insert this lines:

JHtml::_('script', com_myComponent/js/file.js', false, true);
JHtml::_('stylesheet', 'com_myComponent/css/file.css', false, true);

but where I need to insert them?

Thank you so much

1

There are 1 best solutions below

2
Josef Amalraj On

Joomla is very friendly Framework, Very simple to add external libraries

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" >
$document = JFactory::getDocument();
$document->addStyleSheet('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css');

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>

$document->addScript('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js');

Read the Docs https://docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page