5 Easy Steps Converting HTML Template to Joomla Template

Converting an HTML template to a Joomla template is not as hard as you think. Only five easy steps, and you can create and use your Joomla template.

Why you want to learn this? because  perhaps you stumble into beautiful free html templates while browsing on the net and really want to use it for your joomla based website.


Step 1

Prepare your template. The template should be (X)HTML & CSS compliant. There are lot of HTML templates on the Internet, just search them by using uncle Google. Templates in Joomla is filed under  a directory named templates. Ensure the HTML file, images and CSS file are inside one single directory created under templates folder. For example, take a look at the Joomla template structure below:

Joomla Template Directory Structure

Joomla Template Directory Structure

Joomla will search index.php inside the template directory. So, rename the index.html file to index.php.



Step 2

Replace the HTML code before the body tag of your HTML file with this code.

  1. <?php
  2.  
  3. // no direct access
  4. defined( '_JEXEC' ) or die( 'Restricted access' );
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
  8. <head>
  9. <jdoc:include type="head" />
  10.  
  11. <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" />
  12. <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" />
  13. <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/your_template_name/your_css_directory/your_css_file.css" type="text/css" />
  14.  
  15. </head>

You should notice at this code:

  1. <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/your_template_name/your_css_directory/your_css_file.css" type="text/css" />

Change "your_template_name" to the name of your template, "your_css_directory" to name of your css directory, and the last, change "your_css_file.css" to the name of your css file. If you have more than one css file, you should declare them one by one.

If you have some javascript files, you should declare them with the same way.

Step 3

The default Joomla template has a few module positions such as breadcrumbleftrighttopuser1,user2user3user4footerdebugsyndicate. The joomla module positions are shown below.

Joomla Module Position

Joomla Module Position

To create a module position, we need to place this code <jdoc:include type="modules" name="your_module_position_name" /> to apropriate position. The name attribute is the module position name. The snippet code to create a module position is:

  1. <div id="header_r">
  2. <div id="logo"></div>
  3. <jdoc:include type="modules" name="top" />
  4. </div>

After that, you need to place a component. The code is shown below.

  1. <jdoc:include type="component" />

If you need to include message, you only need to include this code:

  1. <jdoc:include type="message" />



Step 4

Create a manifest file. You need to create a manifest file to list all files you used. If you don't create it, it will cause error while installing your template. Here is the sample of a manifest file:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN" "http://dev.joomla.org/xml/1.5/template-install.dtd">
  3. <install version="1.5" type="template">
  4. <name>your_template_name</name>
  5. <creationDate>25/01/2009</creationDate>
  6. <author>Dani Gunawan</author>
  7. <authorEmail>dani.gunawan@yahoo.com</authorEmail>
  8. <authorUrl>http://tobacamp.com</authorUrl>
  9. <copyright></copyright>
  10. <license>GNU/GPL</license>
  11. <version>1.0.0</version>
  12. <description>template description goes here</description>
  13. <files>
  14. <filename>index.php</filename>
  15. <filename>templateDetails.xml</filename>
  16. <filename>template_thumbnail.png</filename>
  17. <filename>images/arrow.png</filename>
  18. <filename>images/logo.png</filename>
  19. <filename>css/template.css</filename>
  20. </files>
  21. <positions>
  22. <position>breadcrumb</position>
  23. <position>left</position>
  24. <position>right</position>
  25. <position>top</position>
  26. <position>user1</position>
  27. <position>user2</position>
  28. <position>user3</position>
  29. <position>user4</position>
  30. <position>footer</position>
  31. <position>debug</position>
  32. <position>syndicate</position>
  33. </positions>
  34. </install>

Don't forget to enlist all your files used in your newly made template inside files tag. If you missed, the files won't be copied to Joomla template directory during installation process. positions tag is used to declare the position name used in your template.

Step 5

Package it. You may create a thumbnail of your template before packing it. It should have 206px width and 150px height . and finally compress your template to a zip file and your template are ready to go. Don't forget to test it before sharing it to the Internet in case you feel like it.

Comments

Popular posts from this blog

உடல் அறிகுறிகள், வலிகள் மற்றும் அவற்றின் சிகிச்சைகள்: வீட்டு சிகிச்சைகள் மற்றும் அக்குபிரஷர் புள்ளிகள்

MySQL table and want to build a XML file with it in order to make a RSS feed.

REST / AJAX calls from within a Jaggery script