Professional Documents
Culture Documents
Contents
1 Introduction
2 Setting up a directory structure
3 Creating a basic templateDetails.xml file
4 Creating a basic index.php file
5 Packaging the template for installation
5.1 Note to Mac OS X users
6 Conclusion
Introduction
The purpose of this tutorial is to serve as an introduction to creating Joomla!
templates. It will cover the essential files and code needed to create a basic
template. The code is presented so it can be cut and pasted with very little
modification needed.
Using a text editor (or dedicated editor such as Adobe Dreamweaver) 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 "style.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.
mynewtemplate/
css/
style.css
images/
index.php
component.php
templateDetails.xml
Thank you.
So, as you can see, we have a set of information between markup tags ( the
<thing> ). Your best approach is to cut and paste this into your
"templateDetails.xml" file and change the relevant bits (such as <name>
<author> ).
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.
Leave the positions as they are - these are a common set so you will be able to
switch easily from the standard templates.
The first line stops naughty people looking at your coding and getting up to bad
things. The second tells the browser (and webbots) what sort of page it is. The
third line says what language the site is in.
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css"
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css"
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template?>/css/style.css"
</head>
The first line gets Joomla to put the correct header information in. This includes
the page title, meta information as well as system JavaScript. The rest creates
links to two system style sheets and to your own style sheet (if it's named
style.css and is located in the css folder).
<body>
<jdoc:include type="modules" name="top" />
<jdoc:include type="component" />
<jdoc:include type="modules" name="bottom" />
</body>
Amazingly, this will suffice! Yes, its a very basic layout, but it will do the job.
Everything else will be done by Joomla!. Note: you will need to ensure your
menu is set to go into the "top" module position.
</html>
If your template is in a directory mytemplate/ then to make the package you can
connect to that directory and use commands like:
export COPYFILE_DISABLE=true
Then in the same terminal window, change directories into where your template
files reside and issue the zip command. For instance, if your template files have
been built in a folder in your personal directory called myTemplate, then you
would do the following:
cd myTemplate
zip -r myTemplate.zip *
Conclusion
You should now have created a template that works. It won't look like much yet.
The best thing to do now is start experimenting with the layout.