Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Articles Thread, Tutorial:Creating a basic Joomla! template in Joomla; Tutorial:Creating a basic Joomla! template Introduction The purpose of this tutorial is to serve as an introduction to creating Joomla! ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=5672


Reply
LinkBack (1) Thread Tools Display Modes
Tutorial:Creating a basic Joomla! template
 
 
The God Father
Developer's Avatar

Reply With Quote
 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
30-10-2008, 04:19 AM
 
Tutorial:Creating a basic Joomla! template



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.
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 (or dedicated editor such as Adobe Dreamweaver) create the files "index.php", "templateDetails.xml"
To keep things organised, make 2 new folders called "images" and "css". Insided the "css" folder create a file called "style.css"
This is the most basic practical setup. Theoretically, the css could be missed out but if you place the styling information within your "index.php" it will bloat the size of webpages and give a poor user experience.
Outline of folder and file structure:
  • mynewtemplate/
    • css/
      • style.css
    • images/
    • index.php
    • templateDetails.xml
Egypt.Com EnForum
This article is a small, well-defined item that could be completed by someone with a reasonable knowledge of the subject matter and a modest time commitment. If you would like to try writing this article you're welcome to do so. The subject may be self-evident, but if not then further details should be available on the discussion page. Please add {{inuse}} at the top of this page while editing. For other small, well-defined tasks, please look in the Cookie jar.
Thank you. Creating a basic templateDetails.xml file

The templateDetails.xml file is essential. Without it, your template won't be seen by Joomla!. The file holds key "metadata" about the template.
Lets look at an example:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN"
"http://dev.joomla.org/xml/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>
<filename>template_thumbnail.png</filename>
<filename>images/background.png</filename>
<filename>css/css.css</filename>
</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>
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.
Creating a basic index.php file

The index.php file becomes the core of every page that Joomla! delivers. Essentially, you make a page (like any html page) but place php code where the content of your site should go. Here is the bare bones ready for you to cut and paste.
Lets start at the top:
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
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.
Now the header for real:
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/mynewtemplate/css/style.css" type="text/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 style sheets and JavaScript. The second creates a link to your style sheet. You will need to change this to the directory name that you chose.
Now for the main body:
<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.
Finish it off - one last bit:
</html>

Full template source code:
<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/mynewtemplate/css/style.css" type="text/css" />
</head>
<body>
<jdoc:include type="modules" name="top" />
<jdoc:include type="component" />
<jdoc:include type="modules" name="bottom" />
</body>
</html>
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.
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
Reply

Articles Thread, Tutorial:Creating a basic Joomla! template in Joomla; Tutorial:Creating a basic Joomla! template Introduction The purpose of this tutorial is to serve as an introduction to creating Joomla! ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=5672


Bookmarks

Tags
basic, joomla, template, tutorialcreating


LinkBacks (?)
LinkBack to this Thread: http://forum.egypt.com/enforum/articles-f141/tutorial-creating-basic-joomla-template-5672.html
Posted By For Type Date
Tutorial:Creating a basic Joomla! template - Egypt Forums - Codehead Webmaster Forums This thread Refback 20-04-2009 03:34 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Joomla! 1.5 Template Tutorial Developer Articles 5 21-01-2009 03:31 PM
Tutorial:Upgrading a Joomla! 1.0.x template Developer Articles 0 30-10-2008 04:15 AM
HTML A basic Webpage structure Tutorial Developer Articles 0 17-10-2008 09:07 PM
Tutorial: Creating Buttons for Your Forum (Photoshop) Developer Articles 0 09-09-2008 08:13 PM
BeautyInDesign.Joomla.Template.Joomla.OS.1.0-NiGHTNiNG Developer Templates for Joomla 1.5 0 18-08-2008 08:33 PM