Actions

User

Difference between revisions of "Rvsjoen/tutorial/Developing a Template/Part 01"

From Joomla! Documentation

< User:Rvsjoen‎ | tutorial/Developing a Template
(Creating the manifest)
(Creating the index file)
Line 15: Line 15:
 
'''<tt>index.php</tt>'''
 
'''<tt>index.php</tt>'''
 
<source lang="php">
 
<source lang="php">
 
+
<?php
 +
 +
/**
 +
* @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;
 +
 +
?>
 +
<?php echo '<?'; ?>xml version="1.0" encoding="<?php echo $this->_charset ?>"?>
 +
<!DOCTYPE html>
 +
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
 +
<head></head>
 +
<body></body>
 +
</html>
 
</source>
 
</source>
 
</span>
 
</span>

Revision as of 04:53, 16 April 2012

Contents

Developing a Basic Template

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

This is where it all starts, the "root" of your template so to speak.

With your favorite editor, create the following file

index.php

<?php
 
/**
 * @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;
 
?>
<?php echo '<?'; ?>xml version="1.0" encoding="<?php echo $this->_charset ?>"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
        <head></head>
        <body></body>
</html>

Creating the manifest

With your favorite editor, create the following file

templateDetails.xml

<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="template" client="site">
        <name>helloworld</name>
        <creationDate>Once upon a time</creationDate>
        <author>John Doe</author>
        <authorEmail>john.doe@example.org</authorEmail>
        <authorUrl>http://www.example.org</authorUrl>
        <copyright>Copyright Info</copyright>
        <license>License Info</license>
        <version>0.0.1</version>
        <description>Description of the Hello World! template...</description>
        <files>
                <filename>index.php</filename>
                <filename>templateDetails.xml</filename>
        </files>
</extension>

Installation and Testing

Before testing your shiny new module 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

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

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

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

Download this part