Difference between revisions of "Creating a basic Joomla! template"

From Joomla! Documentation

m (1 revision(s))
Line 1: Line 1:
 +
Setting up a directory structure
 +
 
{{:Setting up a directory structure|Setting up a directory structure}}
 
{{:Setting up a directory structure|Setting up a directory structure}}
  

Revision as of 07:25, 2 May 2008

Setting up a directory structure

To make the most basic template, create a new folder in the templates folder. Name this folder after your template i.e. mynewtemplate.

Using a text editor create the files index.php and templateDetails.xml.

To keep things organized, make 2 new folders called images and css. Inside the css folder create a file called template.css.

Although it is fine to place all your CSS code directly in your index.php file to start, many web developers prefer to place their CSS code in a separate file that can be linked from multiple pages using the link tag. This may also shorten the loading time of your pages, since the separate file can be cached.

This is the most basic practical setup.

Outline of folder and file structure:

  • mynewtemplate/
    • css/
      • template.css
    • images/
    • index.php
    • templateDetails.xml

How to edit the files


<translate>The templateDetails.xml file is essential. Without it, your template won't be seen by Joomla!. The file holds key metadata about the template.</translate>

<translate>The syntax of the file is different for each Joomla version.</translate>

<translate>For Joomla 3.x and later, use the following version. Change version="2.5" in the extension tag into the version of your Joomla! installation (3.1 etc) or the minimum version that you wish to support.</translate>

<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="template">
	<name>mynewtemplate</name>
	<creationDate>2008-05-01</creationDate>
	<author>John Doe</author>
	<authorEmail>john@example.com</authorEmail>
	<authorUrl>http://www.example.com</authorUrl>
	<copyright>John Doe 2008</copyright>
	<license>GNU/GPL</license>
	<version>1.0.2</version>
	<description>My New Template</description>
	<files>
		<filename>index.php</filename>
		<filename>templateDetails.xml</filename>
		<folder>images</folder>
		<folder>css</folder>
	</files>
	<positions>
		<position>breadcrumb</position>
		<position>left</position>
		<position>right</position>
		<position>top</position>
		<position>user1</position>
		<position>user2</position>
		<position>user3</position>
		<position>user4</position>
		<position>footer</position>
	</positions>
</extension>

<translate>For Joomla 1.5, use the following:</translate>

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.5/template-install.dtd">
<install version="1.5" type="template">
	<name>mynewtemplate</name>
	<creationDate>2008-05-01</creationDate>
	<author>John Doe</author>
	<authorEmail>john@example.com</authorEmail>
	<authorUrl>http://www.example.com</authorUrl>
	<copyright>John Doe 2008</copyright>
	<license>GNU/GPL</license>
	<version>1.0.2</version>
	<description>My New Template</description>
	<files>
		<filename>index.php</filename>
		<filename>templateDetails.xml</filename>
		<folder>images</folder>
		<folder>css</folder>
	</files>
	<positions>
		<position>breadcrumb</position>
		<position>left</position>
		<position>right</position>
		<position>top</position>
		<position>user1</position>
		<position>user2</position>
		<position>user3</position>
		<position>user4</position>
		<position>footer</position>
	</positions>
</install>

<translate>So, as you can see, we have a set of information between markup tags (the <element>s). Your best approach is to cut and paste this into your templateDetails.xml file and change the relevant bits (such as <name> and <author>).</translate>

<translate>The <files> part should contain all the files that you use - you possibly don't know what they are called yet - don't worry, update it later. The <folder> element can be used to define an entire folder at once.</translate>

<translate>Leave the positions as they are - these are a common set so you will be able to switch easily from the standard templates.</translate> <translate> </translate> (not needed???)

Creating a basic index.php file

Testing the template