Adding Bootstrap to Joomla Template

Bootstrap Template can be added to the existing joomla template if they are not one or you can also add it to your own customized theme. You can download the necessary Bootstap files from the official site(http://getbootstrap.com/). To add Bootstrap to our template, we have to include the following files

  • bootstrap.css (or bootstrap.min.css)
  • bootstrap.js (or bootstrap.min.js)

Actually what Joomla does is that, it automatically adds few JavaScript and CSS files. Instead of the following line,

<jdoc:include type=”head” />

Joomla will replace with,

<script src=”/media/system/js/mootools-core.js” type=”text/javascript”></script>
<script src=”/media/system/js/core.js” type=”text/javascript”></script>
<script src=”/media/system/js/caption.js” type=”text/javascript”></script>
<script src=”/media/system/js/mootools-more.js” type=”text/javascript”></script>
<script src=”/media/jui/js/jquery.min.js” type=”text/javascript”></script>
<script src=”/media/jui/js/jquery-noconflict.js” type=”text/javascript”></script>
<script src=”/media/jui/js/bootstrap.min.js” type=”text/javascript”></script>

Since Joomla itself adds bootstrap js file by default, we have to add only the bootstrap css file.Go to the index.php file of the template folder. Add the following code in the index.php at the top,

<?php

$doc = JFactory::getDocument();

$doc->addStyleSheet($this->baseurl . ‘/media/jui/css/bootstrap.min.css’);

?>

Thats it. Now the bootstrap has been added to the template and you can see the difference.

Advertisements

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