How to Include CSS and Javascript files in a Joomla Template?

> Please open your index.php to edit

> Pleae use $doc->addStyleSheet to include the CSS file and $doc->addScript to add the JS files

> Please also add $doc = JFactory::getDocument() at the start

 

 

<?php

$doc = JFactory::getDocument();

$doc->addStyleSheet('templates/' . $this->template . '/css/style.css');
$doc->addScript('/templates/' . $this->template . '/js/main.js', 'text/javascript');

?>

<!DOCTYPE html>
<html>

<head>

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Enable Two Factor Authentication in Joomla 3.5?

> Please login to Joomla admin dashboard > You will have a notification, please click on...

How to Change an Article Category in Joomla 3.5?

> Please login to your Joomla 3.5 Admin Dashboard > Please go to Content > click...

How to Create a New Category in Joomla 3.5?

> Please login to Joomla 3.5 Admin Dashboard > Please click on the Content > Catagory...

How to Create a New Article in Joomla 3.5?

> Please login to your Joomla 3.5 Admin Dashboard > Please Click Content > Articles...

How to Log in to your Joomla 3.5 Dashboard?

> Please navigate your site with "/administrator", for e.g. domain.com/administrator >...

Powered by WHMCompleteSolution