Creating a Pure CSS Template in Joomla!
In this chapter, we'll go through the steps of creating a Joomla template. Specifically, we will create a template that uses Cascading Style Sheets (CSS) to produce a layout without use of tables. This is a desirable goal because it means that the template code is easier to validate to World Wide Web Consortium (W3C) standards. It also tends to load faster, be easier to maintain, and perform better in search engines. These issues are discussed in detail later in the chapter.
In This Chapter
- What is a Joomla template? What functions are performed by a Joomla template, and what is the difference when a template has no content versus when content is added into the Content Management System (CMS).
- How does the localhost design process differ to that of a static (X)HTML web page?
- What are the implications of tableless designs in Joomla and the relationship between W3C standards, usability, and accessibility?
- What files make up a Joomla template, and what functions do they perform?
- How do you create a source-ordered 3-column layout using CSS rather than tables?
- What are the basic CSS styles that should be used with Joomla, and what are the default styles that are used by the Joomla core?
- How do you place and style modules, and what are some new techniques for rounded corners?
- How do you control when columns are shown and hide them when no content is present?
- What are the proper steps to create a real Joomla 1.5 template?
What Is a Joomla Template?
A Joomla template is a series of files within the Joomla CMS that control the presentation of the content. The Joomla template is not a website; it's also not considered a complete website design. The template is the basic foundation design for viewing your Joomla website. To produce the effect of a "complete" website, the template works hand in hand with the content stored in the Joomla databases. An example of this can be seen in Figure 9.1.
Figure 9.1 Template with and without content
Figure 9.1, part A, shows the template in use with sample content. Part B shows the template as it might look with a raw Joomla installation with little or no content. The template is styled so that when your content is inserted, it will inherit the stylesheet defined in the template such as link styles, menus, navigation, text size, and colors to name a few.
Notice that the images associated with the content (the photos of the people) are not part of the template but the header is.
Using a template for a CMS, as Joomla does, has a number of advantages and disadvantages:
- There is a complete separation of content and presentation, especially when CSS is used for layout (as opposed to having tables in the index.php file). This is one of the main criteria for a site that meets modern web standards.
- A new template, and hence a completely new look to a website, can be applied instantly. This can even have different locations/positioning of content as well as colors and graphics.
- If different layouts are called for within one website, it can be difficult to achieve.
Although different templates can be applied to different pages, this built-in functionality is not reliable. Much better is to use conditional PHP and create a layout that dynamically adjusts the number of columns based on what content is published.