Joomla Templates: Creating a Pure CSS Template | Part 2 | WebReference

Joomla Templates: Creating a Pure CSS Template | Part 2


[next]

Joomla Templates: Creating a Pure CSS Template - Part 2

By Barrie North

Digg This Add to del.icio.us

templateDetails.xml

The templateDetails.xml must include all the files that are part of the template. It also includes information such as the author and copyright. Some of these are shown in the admin backend in the Template Manager. An example XML file is shown here:

Let's explain what some of these lines mean:

  • <install version="1.5" type="template">. The contents of the XML document are instructions for the backend installer. The option type="template" tells the installer that we are installing a template and that it is for Joomla 1.5.
  • <name>TemplateTutorial15. Defines the name of your template. The name you enter here will also be used to create the directory within the templates directory. Therefore it should not contain any characters that the file system cannot handle, for example spaces. If installing manually, you need to create a directory that is identical to the template name.
  • <creationdate>August 2007. The date the template was created. It is a free form field and can be anything such as May 2005, 08-June-1978, 01/01/2004, and so on.
  • <author>Barrie North. The name of the author of this templateâ€"most likely your name.
  • <copyright>GPL. Any copyright information goes into this element. A Licensing Primer for Developers and Designers can be found in the Joomla forums.
  • <authoremail>compassdesigns@gmail.com. Email address where the author of this template can be reached.
  • <authorurl>www.compassdesigns.net. The URL of the author's website.
  • <version>1.0. The version of this template.
  • <files>. Various files used in the template.

The files used in the template are laid out with <filename> tags:

  • The "files" sections contain all generic files like the PHP source for the template or the thumbnail image for the template preview. Each file listed in this section is enclosed by <filename> </filename>. Also included would be any additional files; here the example of a JavaScript file that is required by the template is used.
  • All image files that the template uses are also listed in the section. Again, each file listed is enclosed by <filename> </filename>. Path information for the files is relative to the root of the template. For example, if the template is in the directory called 'YourTemplate', and all images are in a directory 'images' that is inside 'YourTemplate', the correct path is: <filename>images/my_image.jpg</filename>.
  • Last, any stylesheets are listed in the files section. Again, the filename is enclosed by , and it's path is relative to the template root.
  • <positions>. The module positions available in the template.
  • <params>. These describe parameters that can be passed to allow advanced template functions such as changing the color of the template.

index.php

What actually is in an index.php file? It is a combination of (X)HTML and PHP that determines everything about the layout and presentation of the pages.

First, let's look at a critical part of achieving valid templates, the DOCTYPE at the top of the index.php file. This is the bit of code that goes at the very top of every web page. At the top of our page, we have this in our template:

The first PHP statement simply makes sure that the file is not accessed directly for security.

A web page DOCTYPE is one of the fundamental components of how a web page is shown by a browser, specifically, how that browser interprets CSS. To give you further understanding, an observation from alistapart.com says

Information on W3C's site about DOCTYPEs is written by geeks for geeks. And when I say geeks, I don't mean ordinary web professionals like you and me. I mean geeks who make the rest of us look like Grandma on the first day of She's Got Mail.

Anyway, you can use several DOCTYPEs. Basically, the DOCTYPE tells the browser how to interpret the page. Here the words "strict" and "transitional" start getting floated around (float:left and float:right usually). Essentially, ever since the Web started, different browsers have had different levels of support for CSS. This means for example, that Internet Explorer won't understand the "min-width" command to set a minimum page width. To duplicate the effect, you have to use "hacks" in the CSS.

NOTE

Some say that serving (X)HTML as text/html is considered harmful. If you actually understand that statement you are well ahead of the game and beyond this guide. You can read more at hixie.ch/advocacy/xhtml.

Strict means the HTML (or (X)HTML) will be interpreted exactly as dictated by standards. A transitional DOCTYPE means that the page will be allowed a few agreed upon differences to the standards.

To complicate things, there is something called "quirks" mode. If the DOCTYPE is wrong, outdated, or not there, the browser goes into quirks mode. This is an attempt to be backwards-compatible, so Internet Explorer 6 for example, will render the page pretending as if it were IE4.

Unfortunately, people sometimes end up in quirks mode accidentally. It usually happens in two ways:

  • They use the DOCTYPE declaration straight from the WC3 web page, and the link ends up as DTD/xhtml1-strict.dtd, except this is a relative link on the WC3 server. You need the full path as shown earlier.
  • Microsoft set up IE6 so you could have valid pages but be in quirks mode. This happens by having an "xml declaration" put before the DOCTYPE.

Next is an XML statement (after the DOCTYPE):

The part about IE6 quirks mode is important. In this chapter we only design for IE6+, so we will make sure that it's running in standards mode. This will minimize the hacks we have to do later on.

NOTE

Making a page standards-compliant, where you see "valid xhtml" at the bottom of the page does not mean really difficult coding, or hard-to-understand tags. It merely means that the code you use matches the DOCTYPE you said it would. That's it! Nothing else.

Designing your site to standards can, on one level, be reduced to saying what you do and then doing what you say.

Here are some useful links, which will help you understand DOCTYPE and quirks mode:


[next]

URL: