Rvsjoen/tutorial/Developing a Template/Part 01

From Joomla! Documentation

< User:Rvsjoen‎ | tutorial/Developing a Template

Developing a Basic Template[edit]

Alright, lets get cracking on this awesome adventure towards template independence. Creating a basic template is in reality pretty simple, all we need is two things.

  • A template manifest
  • A template index file

Creating the index file[edit]

This is where it all starts, the "root" of your template so to speak, this file is responsible for rendering a properly structured HTML document. This file will exists in all templates.

With your favorite editor, create the following file


 * @package     Joomla.Tutorials
 * @subpackage  Template
 * @copyright   Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @license     License GNU General Public License version 2 or later; see LICENSE.txt
// No direct access to this file
defined('_JEXEC') or die;
<!DOCTYPE html>
<html xmlns="" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>">
		<jdoc:include type="head" />
		<jdoc:include type="message" />
		<jdoc:include type="component" />

As you can see, this is a very basic PHP file, yet in only a few lines of markup we have accomplished the following things

  • We have declared the document type to be <!DOCTYPE html> which means that we are creating a HTML5 template. For a complete list of recommended doctypes please see [1]
  • We have enforced that our document must conform to the XHTML namespace through the xmlns attribute
  • We have included a head in the html document
  • We have included a body in the html document

Pay special attention to the jdoc include tags, these are what makes Joomla! able to insert content into your template. For now, we told Joomla! to include all header-specific information inside the <head> element. We also told Joomla! that we want system messages to appear in the top of the <body> element and that we want to include the component here as well. The component is the main part of a rendered Joomla! page such as an article.

There are several other types of jdoc include tags that we will cover later in this tutorial. What is important to know is that whenever you see one of them, it means that Joomla! may or may not insert content in it's location.

Creating the manifest[edit]

With your favorite editor, create the following file


<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="template" client="site">
        <creationDate>Once upon a time</creationDate>
        <author>John Doe</author>
        <copyright>Copyright Info</copyright>
        <license>License Info</license>
	<description>Description of the Hello World! template...</description>

Installation and Testing[edit]

Before testing your shiny new template you have to install it. In Joomla! there are two ways of doing that, either by packaging the extension into an installable zip package or by using the discovery method. Both methods are described below but I recommend using the packaged zip file as a beginner because it is more hostile towards errors especially in the XML manifest.

Installing your template[edit]

If you have used Joomla before reading this tutorial, you have noticed that extensions are installed using a compressed file containing all the things which are needed for installing and uninstalling them.

A new feature made available in Joomla! 1.6 is "discover." That means you can place the files in the correct places inside your Joomla! installation (The proper file path for this module will be in templates/helloworld within the Joomla! root), and the "Discover" option within the extension manager will install it, when selected.

Packaging an installation zip file[edit]

Create a compressed file of your extension directory using the structure shown in the file listing section of this page or download the provided installable package.

When you have this package, install it using the extension manager.

Testing your template[edit]

If you want to test this template, you first need to do a couple of things.

  1. Go to the Template Manager
  2. Set your shiny new template to the default template for Site

After performing these steps you can navigate to the frontend and view the template.

File listing[edit]

Download this part[edit]

Articles in this series[edit]

This tutorial is supported by the following versions of Joomla!

Joomla 2.5