Joomla

Joomla

June 8, 2019

According to Joomla official  documentation, “A template is a type of Joomla! extension that changes the way your site looks. There are two types of templates used by the Joomla! CMS: Front-end Templates and Back-end Templates. The Front-end Template controls the way your website is presented to the user viewing the website’s content. The Back-end Template controls the way your website’s administrative tasks are presented for controlling management functions by a Joomla! Administrator. These would include common tasks such as: user, menu, article, category, module, component, plugin and template management.”

Premium Joomla Templates:

There are many websites where you can buy premium Joomla templates. We are listing some popular websites below.

  1. Joomla Templates from ThemeForest – themeforest.net‎
  2. Joomla Templates – JoomDev
  3. Joomla Templates – TemplateMonster
  4. Joomla Templates Collection – JoomShaper
  5. And more…

How to create basic Joomla! Template? (For Developers)

If you are familiar with PHP programming  language, you can easily create Joomla Templates. Joomla CMS supports PHP language, so creating template in joomla we should knowledge of PHP programming language. So let’s start…

Step I: 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. myfirstjoomlatemplate.

Using your favourite 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:

Step II: 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.

The syntax of the file is different for each Joomla version.

For V1.5 , use the following:

<?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>

For V2.5 and later, use the following version. Change version=”2.5″ into the version of your Joomla! installation.

<?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>

So, as you can see, we have a set of information between markup tags (the <element>s). Your best approach is to copy and paste this into your templateDetails.xml file and change the relevant bits (such as <name> and <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. The <folder> element can be used to define an entire folder at once.

Leave the positions as they are – these are a common set so you will be able to switch easily from the standard templates.

Step III: 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. The template works by adding Joomla code into module positions and the component section in your template. Anything added to the template will appear on all pages unless it is added to one of these sections via the Joomla CMS (or customised code).This page will show the bare-bones code ready for you to cut and paste into your own design.A Joomla template begins with the following lines:

<?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
<!DOCTYPE html>
<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 line is the Document Type Declaration (DOCTYPE), which tells the browser (and web crawlers) which flavor of HTML the page is using. The doctype used above is HTML5, a newer version of HTML that is largely backwards compatible, but contains many new features. You should be aware that this will not work well in Internet Explorer 8 or earlier without a hack. You might want to investigate this situation and your clients’ wishes before deciding on which doctype you want to use. However this is used in Joomla and higher.

The third line begins our HTML document and describes what language the website is in. A html document is divided into two parts, head and body. The head will contain the information about the document and the body will contain the website code which controls the layout.

Head

<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/template.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 JavaScript. The rest creates links to two system style sheets and to your own style sheet (if it’s named template.css and is located in the css folder of your template directory. So if your template is in http://www.mysite.com/templates/my_template/ then the css files will go in http://www.mysite.com/templates/my_template/css/).