| Joomla 1.5 Template Tutorial |
Creating a pure CSS layout Joomla 1.5 templateIn 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 will also tend 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
This sample content is excerpted from the forthcoming book, titled Joomla! A User's Guide: Building a Joomla! Powered Website, to publish in 2007, by Prentice Hall Professional.
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, 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:
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. The Least You Need to Know Localhost Design ProcessThe web page you see at a Joomla-powered website is not static. That means it is generated dynamically from content stored in the database. The page that you see is created through various PHP commands that are in the template, which presents some difficulties in the design phase. It's common now to use a what you see is what you get (WYSIWYG) HTML editor, such as Dreamweaver. This means that the designer does not even need to code the HTML. However, this is not possible in the Joomla template design process because WYSIWYG editors cannot display a dynamic page. This means that the designer must code "by hand" and view the output page from the PHP on a served page. With a fast enough connection this could be a web server, but most designers use a "local server" on their own computer. This is a piece of software that will serve the web pages on the designer's computer. There is no "right way" to create a web page; it depends on the designer's background. Those more graphics-inclined make an "image" of a page in a graphics program like Photoshop and then break up the images to be able to use them for the Web (known as slice and dice). More technology-based designers will often just jump straight into the CSS and start coding. However, as just mentioned, the Joomla template designer is limited in that he cannot instantly see the effect of his coding in the same editor. The modified design process is as follows:
The Least You Need to Know Localhost Server OptionsIn Chapter 2, we saw how to install a web server that will run on your computer. We described one for a localhost webserver called WAMP5. To move further along in this chapter, you will need to have this installed. If you haven't yet, go ahead and install it. I'll wait right here. TIP NOTE W3C and Tableless DesignUsability, accessibility, and search engine optimization (SEO) are all phrases used to describe high-quality web pages on the Internet today. In reality, there is a significant amount of overlap between usability, accessibility and SEO and a web page that demonstrates the characteristics of one does so for all three; this is shown in Figure 9.2. The easiest way to achieve these three goals is to do so using the framework laid out in the World Wide Web Consortium (W3C) web standards. For example, a site that is structured semantically with (X)HTML (the XHTML explains the document, not how it looks) will be easily read through a screen reader by someone who has poor vision. It will also be easily read by a search engine spider. Google is effectively blind in how it reads your website, itÙs as though it is using a screen reader.
Web standards put into place a common set of "rules" for all web browsers to use to display a web page. The main organization pushing these standards is the World Wide Web Consortium (WC3), whose Director, Tim Berners-Lee, has the distinction of actually inventing the Web in 1989. To help you understand where web standards came from, some history is helpful. Many web pages are actually designed for older browsers. Why? Browsers have continually evolved since the World Wide Web started. New ones have appeared, and some old ones have disappeared (remember Netscape?). Another complicating factor is that different browser makers (like Microsoft) tend to have their browsers interpret html/xhtml in slightly different ways. This has lead to web designers having to design their websites to support older browsers rather than new ones. It's often decided that it's important that a web page appear properly to these "legacy" browsers. The WC3 standards outlined for web page code have been developed to achieve consistency. A site that incorporates the W3C's web standards has a much better foundation for making itself accessible, usable, and search engine-optimized. Think of these as building codes for your house. A website built with them is stronger and safer and coincides with users' expectations. You can check your pages with the W3C's HTML validation service (validator.w3.org/). It's easy and free (make sure you use the correct DOCTYPE when you try and validate your code1). At its simplest, a site that meets W3C validation uses semantic (X)HTML and separates content from presentation using CSS. Ask five designers what web standards are, and you will get five different answers. But most agree that they are based on using valid code, whether HTML or XHTML (or others). Semantically Correct CodeAs was mentioned earlier, being semantic means that the (X)HTML in the web page describes only content, not presentation. In particular, this means structured organization of H1,H2 tags etc and only using tables for tabular data, not layout. Cascading Style Sheets (CSS)Closely related to having semantic code, is using Cascading Style Sheets (CSS) to control the look and layout of a web page. CSS is a simple mechanism for adding style (that is, fonts, colors, spacing, and so on) to Web documents (source: www.w3.org/Style/CSS/). They exist parallel to the (X)HTML code and so let you completely separate content (semantic code) from presentation (CSS). The best example of this is CSS Zen Garden, a site where the same semantic XHTML is shaped in different and unique ways with different CSS. The result is pages that look very different but have the same core content. Designing Joomla-powered sites currently presents considerable challenges to meet validation standards. In the first series of releases, 1.0.X, the code used a significant amount of tables to output its pages. This isn't really using CSS for presentation, nor does it produce semantically correct code. This problem is compounded by the fact that very few third-party developers are using CSS; most use tables to generate their code too. Fortunately, the Joomla Core Development team recognized this issue with Joomla. In the 1.5 version, it's possible for template designers to completely override the output of the core (called a view) and strip out the tables or customize the layout[md]whatever they want. Regardless, care can still be taken when creating a template to make sure it is accessible (for example, scalable font sizes), usable (clear navigation) and optimized for search engines (source-ordered). The Least You Need to Know
This sample content is excerpted from the forthcoming book, titled Joomla! A User's Guide: Building a Joomla! Powered Website, to publish in 2007, by Prentice Hall Professional. Creating a Simple Blank TemplateTo understand the contents of a template, we will start by looking at a blank Joomla template. The Template File ComponentsThe template contains the various files and folders that make up a Joomla template. These files must be placed in the /templates/ directory of a Joomla installation in their own folder. So if we had two templates installed, our directory would look something like the following: /templates/element
/templates/voodoo Note that the directory names for the templates must be the same as the name of the template, in this case element and voodoo. Obviously they are case sensitive and shouldn't contain spaces. /element/templateDetails.xml
/element/index.php These two filenames and location must match exactly because this is how they are called by the Joomla core script. The first of these is the template XML file. templateDetails.xmlThis is an XML format metadata file that tells Joomla what other files are needed when loading a web page that uses this template. Note the uppercase "D." It also details the author, copyright, and what files make up the template (including any images used). The last use of this file is for installing a template when using the admin backend. Second, we have the engine of the template, the index.php: index.phpThis file is the most important. It lays out the site and tells the Joomla CMS where to put the different components and modules. It is a combination of PHP and (X)HTML. In almost all templates, additional files are used. It is conventional (although not required by the core) to name and locate them as shown here: /element/template_thumbnail.png
/element/css/template.css /element/images/logo.png These are just examples. Table 9.1 examines each line. Table 9.1
templateDetails.xmlThe 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: <?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="template"> <name>TemplateTutorial15</name> <creationDate>August 2007</creationDate> <author>Barrie North</author> <copyright>GPL</copyright> <authorEmail> This e-mail address is being protected from spambots. You need JavaScript enabled to view it </authorEmail> <authorUrl>www.compassdesigns.net</authorUrl> <version>1.0</version> <description>First example template for Chapter 9 of the Joomla Book</description> <files> <filename>index.php</filename> <filename>templateDetails.xml</filename> <filename>js/somejsfile.js</filename> <filename>images/threecol-l.gif</filename> <filename>images/threecol-r.gif</filename> <filename>css/customize.css</filename> <filename>css/layout.css</filename> <filename>css/template_css.css</filename> </files> <positions> <position>user1</position> <position>top</position> <position>left</position> <position>banner</position> <position>right</position> <position>footer</position> </positions> <params> <param name="colorVariation" type="list" default="white" label="Color Variation" description="Color variation to use"> <option value="blue">Blue</option> <option value="red">Red</option> </param> </params> </install> Let's explain what some of these lines mean:
<files>
<filename>index.php</filename> <filename>templateDetails.xml</filename> <filename>js/somejsfile.js</filename> <filename>images/threecol-l.gif</filename> <filename>images/threecol-r.gif</filename> <filename>css/customize.css</filename> <filename>css/layout.css</filename> <filename>css/template_css.css</filename> </files>
index.phpWhat 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: <?php // no direct access 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"> 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 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. Some say that serving XHTML 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. 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:
Next is an XML statement (after the DOCTYPE): <html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" > 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 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:
What Else Is in index.php?Let's look at the structure of the header first; we want to be as minimal as possible but still have enough for a production site. The header information we will use is as follows: <?php // no direct access 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="/templates/system/css/system.css" type="text/css" /> <link rel="stylesheet" href="/templates/system/css/general.css" type="text/css" /> <link rel="stylesheet" href="/templates/<?php echo $this->template ?>/css/template.css" type="text/css" /> </head> What does all that mean? We have already discussed the implications of the DOCTYPE statement in the index.php file. The <?php echo $this->language; ?> is pulling the language from the site Global Configuration. The next line is to include more header information: <jdoc:include type="head" />
This is all header information that is set in the Global Configuration again. It includes the following tags (in a default installation): <title>Welcome to the Frontpage</title>
<meta name="description" content="Joomla! - the dynamic portal engine and content management system" /> <meta name="generator" content="Joomla! 1.5 - Open Source Content Management" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="index, follow" /> <meta name="keywords" content="joomla, Joomla" /> <link href="/feed/rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" /> <link href="/feed/atom" rel="alternate" type="application/atom+xml" title="Atom 1.0" /> <script type="text/javascript" src="http://localhost/Joomla-1.5RC2/media/system/js/mootools.js"></script> <script type="text/javascript" src="http://localhost/Joomla-1.5RC2/media/system/js/caption.js"></script> Much of this header information is created on the fly specific to the page (article) that someone is on. It includes a number of metatags[md]the favicon, RSS feed URLs, and some standard JavaScipt files. The last lines in the header provide links to CSS files for the template: <link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="/templates/system/css/general.css" type="text/css" /> <link rel="stylesheet" href="/templates/<?php echo $this->template ?>/css/template.css" type="text/css" /> The first two files, system.css and general.css contain some generic Joomla styles. The last one is all the CSS for the template, here called template.css. The PHP code <?php echo $this->template ?> will return the name of the current template. Writing it in this way rather than the actual real path makes the code more generic. When you create a new template you can just copy it (along with the whole header code) and not worry about editing anything. The template CSS files can have any number of files, for example conditional ones for different browsers. This one targets IE6: <!--[if lte IE 6]>
<link href="/templates/<?php echo $this->template ?>/css/ieonly.css" rel="stylesheet" type="text/css" /> <![endif]--> This example is part of a technique to use a template parameter: <link rel="stylesheet" href="/templates/<?php echo $this->template ?>/css/<?php echo $this->params->get('colorVariation'); ?>.css" type="text/css" />
Blank Joomla 1.5 Template BodyCreating our first template will be very very easy! Ready? All we need to do is use Joomla statements that insert the contents of any modules and the mainbody. <body>
<?php echo $mainframe->getCfg('sitename');?><br /> <jdoc:include type="module" name="breadcrumbs" /> <jdoc:include type="modules" name="top" /> <jdoc:include type="modules" name="left" /> <jdoc:include type="component" /> <jdoc:include type="modules" name="right" /> </body> At this point (if you preview it), our site does not look very awe inspiring. The output is shown in Figure 9.3.
The template contains the following in reasonably logical order:
The Least You Need to Know The goal is to try and come as close to semantic markup as possible. From a Web point of view, it means a page can be read by anyone[md]a browser, a spider, or a screen reader. Semantic layout is the cornerstone of accessibility. NOTE You will notice that we have used the first of a number of commands specific to Joomla to create this output: <?php echo $mainframe->getCfg('sitename');?><br />
<jdoc:include type="module" name="breadcrumbs" /> <jdoc:include type="modules" name="top" /> <jdoc:include type="modules" name="left" /> <jdoc:include type="component" /> <jdoc:include type="modules" name="right" /> The PHP echo statement simply outputs a string from the configuration.php file. Here, we are using the site name; we could as easily have had the following: The name of this site is <?php echo $mainframe->getCfg('sitename');?><br />
The administrator email is <?php echo $mainframe->getCfg('mailfrom');?><br /> This template is in the <?php echo $this->template?> directory<br /> The URL is <?php echo JURI::base();;?> The jdoc statement inserts various types of XHTML output, either from modules of components. <jdoc:include type="component" />
NOTE This line inserts the output for a module location: <jdoc:include type="modules" name="right" />
The full syntax is actually <jdoc:include type="modules" name="LOCATION" style="OPTION" />
We look at the various options for styles in the section about modules later in this chapter. CSSTemplateTutorialStep1At this point we have a very bare template. I have created an installable template that is available from the Compass library: CSSTemplateTutorialStep1.zip. This will install a template that has only two files, the index.php and templateDetails.xml. I removed references to other files to give a bare bones output with no CSS. This is actually a useful diagnostic template; you can install it and track errors that are occurring with a component or module.
This sample content is excerpted from the forthcoming book, titled Joomla! A User's Guide: Building a Joomla! Powered Website, to publish in 2007, by Prentice Hall Professional. Using CSS to Create a Tableless LayoutWe will be using pure CSS to make a 3-column layout for the Joomla template. We will also be making it a fluid layout. There are two main types of web page layout[md]fixed and fluid[md]and they both refer to how the width of the page is controlled. The width of the page is an issue because of the many browser resolutions at which people surf the Web. Although the percentage is dropping, about 17% of surfers are using an 800x600 resolution. The majority, 79%, are using 1024x768 and higher2. Making a fluid layout means that your valuable web page won't be a narrow column in the 1024 resolution and will be visible in full on smaller monitors. A typical design might use tables to layout the page. They are useful in that you just have to set the width of the columns as percentages, but they have several drawbacks. For example, tables have lots of extra code compared to CSS layouts. This leads to longer load times (which surfers don't like) and poorer performance in search engines. The code can roughly double in size, not just with markup but also with something called "spacer gifs." Even big companies sometimes fall into the table trap, as seen by a recent controversy about the new disney.co.uk website3: There are a couple of major problems with a site that uses tables for layout.
Let's look at our layout using CSS. You can position elements (stuff) in several ways using CSS. For a quick introduction, a good source is Brainjar's CSS Positioning. If you are new to CSS, you might read at least one beginner's guide to CSS. Here are a few suggestions:
The Least You Need to Know We will be using float to position our content. At its most basic, the template might look like Figure 9.4. The CSS styles are defined here in the head of the file to show what is going on, but normally they would be in the template.css file. Everything is contained in an element called #wrap. This has a fluid width that ranges between 760px and 960px.
In Figure 9.4, the left, middle, and right columns are each given their own element. Each is floated left and given a percent width that together add up to 100%. The clear:both style on the footer tells the browser to "stop floating" and makes the footer stretch across all three columns. When we build our second template in this chapter, we will have to use a more advanced clearing technique. To improve the layout and to add some breathing room to the content, we need to add some column spacing, commonly called "gutter." Unfortunately, there is a problem here. You might know that Internet Explorer does not interpret CSS correctly. One problem is that it calculates width differently. We can solve this problem by not using any padding or borders on something that has a width. To get our gutter, we add another <div> element inside the columns. To the CSS we add .inside {padding:10px;}
Our resulting <body> code for index.php is: <body>
<div id="wrap"> <div id="header"> <div class="inside"> <?php echo $mainframe->getCfg('sitename');?> <jdoc:include type="modules" name="top" /> </div> </div> <div id="sidebar"> <div class="inside"> <jdoc:include type="modules" name="left" /> </div> </div> <div id="content"> <div class="inside"> <jdoc:include type="component" /> </div> </div> <div id="sidebar-2"> <div class="inside"> <jdoc:include type="modules" name="right" /> </div> </div> <div id="footer"> <div class="inside"> Powered by <a href="http://joomla.org">Joomla!</a>. Valid <a href="http://validator.w3.org/check/referer">XHTML</a> and <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>. </div> </div> </div> <!--end of wrap--> </body> Our template.css file looks like this: #wrap { #content { #footer { .inside { #sidebar,#sidebar-2 { TIP margin-top:5px; margin-bottom:5px; margin-left:10px; margin-right:10px;
can be replaced by: margin: 5px 10px;
There are "shorthand" styles at the beginning of each style definition. After you have figured out the styles, fill the shorthand versions in and delete the long versions. The syntax is: font: font-size |font-style | font-variant | font-weight | line-height | font-family
Here is an example. Rather than using this font-size:1em;
font-family:Arial,Helvetica,sans-serif; font-style:italic; font-weight:bold; line-height:1.3em; use this: font:bold 1em/1.3em Arial,Helvetica,sans-serif italic;
Read more about this syntax at An Introduction to CSS shorthand properties This simple layout is a good one to use for learning about how to use CSS with Joomla because it shows two of the advantages of CSS over table-based layouts, it is less code, and it is easier to maintain. owever, it is not source-ordered. For that we must use a more advanced layout known as a nested float. Default CSSSo far, all of our CSS has been only about layout, which will make a plain page. So let's add some formatting: body { #wrap { #content { #footer { .inside { #sidebar,#sidebar-2 { We have centered the page by using a small hack. This has to be done because Internet Explorer does not read CSS accurately. With a standards-compliant browser, we could just say margin:0 10%; to center the page, but IE does not recognize that, so we center the "text" of the whole page and then align it back left in the columns. In celebration of IE7's support of min/max width (which IE6 does not), we can add in a minimum and maximum width. Note we have to add a tiny hack for IE6 as it does not understand these. It will ignore the !important statement and have a plain, old 960px width. NOTE
We have also added a new style to the columns: overflow:hidden. This will make the page "break" more consistently as we reduce its width. At the beginning of the typography, with CSS we will set some overall styles and have what is known as a global reset: * { h1,h2,h3,h4,h5,h6,p,blockquote, form,label,ul,ol,dl,fieldset,address { li,dd { fieldset { body { Everything is given a zero margin and padding, and then all block level elements are given a bottom margin. This helps achieve browser consistency. You can read more about the global reset at clagnut5 and left-justified. The font size is set to 76%. The reason for this is to try and get more consistent font sizes across browsers. All font sizes are then set in em. Having line-height:1.3 helps readability. This means that the pages will be more accessible because the viewer will be able to resize the fonts to their own preferences. This is discussed more at "An experiment in typography" at The Noodle Incident (Owen Briggs) If we were to add some background colors to the header, sidebars, and content containers, we would see something like what is shown in Figure 9.5.
Notice that the side columns do not reach their footer. This is because they only extend as far as their content; where the space is white on the left and on the right, they don't exist. If we have a template that has a white background for all three columns, this is no problem. We will use this approach and will have boxes around the modules. If we want equal height columns that are colored or have boxes, we have to use a background image that will tile vertically. This technique is called Faux Columns and is described by Douglas Bowman8 and Eric Meyer. Joomla-Specific CSSAlthough Joomla 1.5 has the functionality to override the core output in a template, its default rendering still uses significant tables to output content in the main body. Along with these tables, CSS output is available for a designer to style pages. Based on some research by various community members, Table 9.2 shows the current list. Note it does not include generic web page styles like H1, H2, p, ul, a, form, and so on. Table 9.2
Many designs you might see in Table 9.2 actually have given CSS styles that are more specific in their definitions. Basically, a more specific rule overrides a less specific rule. For example a {color:blue;} a:link {color:red;}
.contentheading {color:blue;} div.contentheading {color:red;} The color on a link and the color of the .contentheading will be red, as that rule is more specific (as .contentheading is contained within a <div>) In the case of Joomla templates, you will often see more specific rules used. This often occurs when the class is on a table. Here are more examples: .moduletable
table.moduletable .moduletable is the name of the <div> that wraps a module. table.moduletable will only apply the style to a table with class="moduletable" on it. .moduletable will apply the style regardless of what element the class is on. a.contentpagetitle:link
.contentpagetitle a:link a.contentpagetitle:link will apply the style to any a tags with a .contentpagetitle class on them that is a link. Specificity is not easy to understand; its often easier to start by using the most general style possible and then getting more specific if the results are not what you expect. Here are some links to websites that discuss specificity in detail:
At the moment, our template is using several tables. As mentioned earlier, this slows the pages down and makes them harder to update. To reduce the number of tables, when we call the modules, we need to use style parameters in the jdoc:include. The Least You Need to Know Modules in TemplatesWhen a module is called in the index.php, it has several options on how it is displayed. <jdoc:include type="modules" name="LOCATION" style="OPTION" />
The style is optional and is defined in templates/system/html/modules.php. Currently, the default modules.php file contains the following layouts. OPTION="table" (default display) modules are displayed in a column. The following shows an example of the output: <table cellpadding="0" cellspacing="0" class="moduletable<?php echo $params->get('moduleclass_sfx'); ?>">
<?php if ($module->showtitle != 0) : ?> <tr> <th valign="top"> <?php echo $module->title; ?> </th> </tr> <?php endif; ?> <tr> <td> <?php echo $module->content; ?> </td> </tr> </table> OPTION="horz" makes the modules appear horizontally. Each module is output in the cell of a wrapper table. The following shows an example of the output: <table cellspacing="1" cellpadding="0" border="0" width="100%">
<tr> <td valign="top"> <?php modChrome_table($module, $params, $attribs); ?> </td> </tr> </table> OPTION="xhtml" makes modules appear as a simple div element. The following shows an example of the output: <div class="moduletable<?php echo $params->get('moduleclass_sfx'); ?>">
<?php if ($module->showtitle != 0) : ?> <h3><?php echo $module->title; ?></h3> <?php endif; ?> <?php echo $module->content; ?> </div> OPTION="rounded" makes modules appear in a format that allows, for example, stretchable rounded corners. If this $style is used, the name of the <div> changes from moduletable to module. The following shows an example of the output: <div class="module<?php echo $params->get('moduleclass_sfx'); ?>">
<div> <div> <div> <?php if ($module->showtitle != 0) : ?> <h3><?php echo $module->title; ?></h3> <?php endif; ?> <?php echo $module->content; ?> </div> </div> </div> </div> OPTION="none" makes modules appear as raw output containing no element and no title. Here is an example: echo $module->content;
As you can see, the CSS options (xhtml and rounded) are much leaner in code, which makes it easier to style the web pages. I don't recommend using suffixes of table (default) or horz unless absolutely needed. Here's the really good bit! If you examine the modules.php file, you will see all the options that exist for modules. It's easy to add your own; this is part of the new templating power that is in 1.5.We will look at this in more details in our section on template overrides. To develop our template, we will put a module style of "xhtml" on all of our modules: <body>
<div id="wrap"> <div id="header"> <div class="inside"> <h1><?php echo $mainframe->getCfg('sitename');?></h1> <jdoc:include type="modules" name="top" style="xhtml" /> </div> </div> <div id="sidebar"> <div class="inside"> <jdoc:include type="modules" name="left" style="xhtml" /> </div> </div> <div id="content"> <div class="inside"> <jdoc:include type="module" name="breadcrumbs" style="none" /> <jdoc:include type="component" /> </div> </div> <div id="sidebar-2"> <div class="inside"> <jdoc:include type="modules" name="right" style="xhtml" /> </div> </div> <div id="footer"> <div class="inside"> <jdoc:include type="modules" name="footer" style="xhtml" /> </div> </div> <!--end of wrap--> </body> Note that we cannot put these module styles on the <jdoc:include type="component" /> because it is not a module. The Least You Need to Know We have also placed the site title inside an <H1> tag. It's more semantically correct and will also help in SEO. Let's also remove the background from the layout divs. We will also add some CSS to style the modules with a border and a background for the module titles. * { h1,h2,h3,h4,h5,h6,p,blockquote, form,label,ul,ol,dl,fieldset,address { li,dd { fieldset { body { #wrap { #header { #footer { a { a:hover { h1,.componentheading { h2,.contentheading { h3 { h4 { h5 { h6 { #footer,.small,.createdate,.modifydate,.mosimage_caption { .moduletable { .moduletable h3 { NOTE This typography CSS now produces the result shown in Figure 9.6.
Menus in TemplatesWe saw in Chapter 5, "Creating Menus and Navigation," that there are a number of settings for how a menu will be rendered. Again, using CSS lists rather than tables results in reduced code and easier markup. After setting all our menus to lists we have only 12 tables (we'll see how to remove the rest using the new version 1.5 override feature). Remember, the list setting is the new 1.5 version; flat list is from 1.0 and will be depreciated. ists are also better than tables because text-based browsers, screen readers, non-CSS supporting browsers, browsers with CSS turned off, and search bots will be able to access your content more easily. A web page at maxdesign.com10 has a selection of over 30 menus, all using the same underlying code. It's called the Listamatic. There is a slight difference in the code that we have to change in order to adapt these menus to Joomla. These lists use the following code: <div id="navcontainer">
<ul id="navlist"> <li id="active"><a href="/ #" id="current">Item one</a></li> <li><a href="#">Item two</a></li> <li><a xhref="#">Item three</a></li> <li><a href="#">Item four</a></li> <li><a href="#">Item five</a></li> </ul> </div> This means that there is an enclosing <div> called navcontainer, and the <ul> has an id of navlist. To duplicate this effect in Joomla, we need have some sort of enclosing <div>. We can achieve this by using module suffixes. If you recall, the output of an XHTML style option module is: <div class="moduletable">
<h3>modChrome_xhtml</h3> modChrome_xhtml </div> If we add a module suffix, that will get added to the moduletable class, like this: <div class="moduletablesuffix">
<h3>modChrome_xhtml</h3> modChrome_xhtml </div> So when picking a menu from Listamatic, you would need to replace the navcontainer class style in the CSS by moduletablesuffix. NOTE This use of a module class suffix is useful. It allows different colored boxes with just a simple change of the module class suffix. The Least You Need to Know For our site we will use List 10 by Mark Newhouse.11 Our CSS will be: .moduletablemenu { .moduletablemenu h3 { .moduletablemenu ul { .moduletablemenu li { .moduletablemenu li a { html>body .moduletablemenu li a { .moduletablemenu li a:hover,a#active_menu:link,a#active_menu:visited { We then need to add the module suffix of menu (no underscore in this case) to any modules of menus we want to be styled. This will produce a menu like what's shown in Figure 9.7. For any menu we want to be styled this way, we have to add "menu" as a module suffix.
TIP <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- .astyle { } --> </style> </head> <body> <div class="moduletable"> <h3>Main Menu</h3> <ul class="mainmenu"> <li id="current" class="item1 active"><a href="#">Home</a></li> <li class="item2"><a href="#">Joomla! Overview</a></li> <li class="item3"><a href="#">What's New in 1.5?</a></li> <li class="item4"><a href="#">Joomla! License</a></li> <li class="item5"><a href="#">More about Joomla!</a></li> <li class="item6"><a href="#">FAQ</a></li> <li class="item7"><a href="#">The News</a></li> <li class="item8"><a href="#">Web Links</a></li> <li class="item9"><a href="#">News Feeds</a></li> </ul> </div> </body> </html> The CSS is embedded instead of linked to make editing easier. Hiding ColumnsSo far, we have our layout such that we always have three columns, regardless of whether there is any content included. From the perspective of a CMS template, this is not very useful. In a static site the content would never change, but we want to give our site administrators the ability to put their content anywhere they want to without having to worry about editing CSS layouts. We want to be able to "turn off" a column automatically or "collapse" it if there is no content there. During the development of the Joomla 1.5 templating engine, there were a number of changes and improvements. Quoting directly from the Joomla development blog: The changes to the template system in Joomla 1.5 can be divided into two categories. First of all there are changes to the way things where done in Joomla 1.0, for example the new way modules are loaded, and second there are also a bunch of extra features, like template parameters[el]a quick overview: mosCountMoules The mosCountModules function has been replaced by the $this->countModules function and support for conditions has been added. This allows designers to easily count the total number of modules in multiple template positions in just one line of code, for example $this->countModules('user1 + user2'); which will return the total number of modules in position user1 and user2. NOTE So the general use of mosCountModules would be: <?php if($this->countModules('condition')) : ?>
do something <?php else : ?> do something else <?php endif; ?> There are four possible conditions. As an example let's count the number of modules in Figure 9.7. We could insert this code somewhere in the index.php: left=<?php echo $this->countModules('left');?><br />
left and right=<?php echo $this->countModules('left and right');?><br /> left or right=<?php echo $this->countModules('left or right');?><br /> left + right=<?php echo $this->countModules('left + right');?>
In this situation, we need to use the function that allows us to count the modules present in a specific location. So for example, if there is no content published in the right column, we can adjust the column sizes to fill that space. There are several ways to do this. We could put the conditional statement in the body to not show the content and then have a different style for the content based on what columns were there. To make it as easy as possible, I have a series of conditional statements in the head tag that (re)define some CSS styles: <?php
if($this->countModules('left and right') == 0) $contentwidth = "100"; if($this->countModules('left or right') == 1) $contentwidth = "80"; if($this->countModules('left and right') == 1) $contentwidth = "60"; ?> So we count:
We then need to change the index.php file in the content div to: <div id="content<?php echo $contentwidth; ?>">
Change the layout css to: #content60 {float:left;width:60%;overflow:hidden;}
#content80 {float:left;width:80%;overflow:hidden;} #content100 {float:left;width:100%;overflow:hidden;} The PHP conditional statements in the head must appear after the line that links to the template.css file. This is because if there are two identical CSS style rules; the one that is last will overwrite all the others. TIP This content column is <?php echo $contentwidth; ?>% wide
So we are half-way there, but now we have empty div containers where the columns are. Hiding Module CodeWhen creating collapsible columns, it is good practice to set up the modules not to be generated if there is no content there. If this is not done, the pages will have empty <div>s in them, which can lead to cross browser issues. To hide the empty <div>, the following if statement is used: <?php if($this->countModules('left')) : ?>
<div id="sidebar"> <div class="inside"> <jdoc:include type="modules" name="left" style="xhtml" /> </div> </div> <?php endif; ?> Using this code, if there is nothing published in left, then <div id="sidebar"> will not be outputted. Using these techniques for our left and right columns, our index.php file now looks like the following code. We will also add an include for the breadcrumbs module, the module that shows the current page and pathway. Note that this now needs to be included in the index.php file and also published as a module. <?php // no direct access 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="/templates/system/css/system.css" type="text/css" /> <link rel="stylesheet" href="/templates/system/css/general.css" type="text/css" /> <link rel="stylesheet" href="/templates/<?php echo $this->template ?>/css/template.css" type="text/css" /> <?php if($this->countModules('left and right') == 0) $contentwidth = "100"; if($this->countModules('left or right') == 1) $contentwidth = "80"; if($this->countModules('left and right') == 1) $contentwidth = "60"; ?> </head> <body> <div id="wrap"> <div id="header"> <div class="inside"> <h1><?php echo $mainframe->getCfg('sitename');?></h1> <jdoc:include type="modules" name="top" style="xhtml" /> </div> </div> <?php if($this->countModules('left')) : ?> <div id="sidebar"> <div class="inside"> <jdoc:include type="modules" name="left" style="xhtml" /> </div> </div> <?php endif; ?> <div id="content<?php echo $contentwidth; ?>"> <div class="inside"> <jdoc:include type="module" name="breadcrumbs" style="none" /> <jdoc:include type="component" /> </div> </div> <?php if($this->countModules('right')) : ?> <div id="sidebar-2"> <div class="inside"> <jdoc:include type="modules" name="right" style="xhtml" /> </div> </div> <?php endif; ?> <?php if($this->countModules('footer')) : ?> <div id="footer"> <div class="inside"> <jdoc:include type="modules" name="footer" style="xhtml" /> </div> </div> <?php endif; ?> <!--end of wrap--> </body> </html> The Least You Need to Know I would recommend a slightly different way of producing the footer. In the manner shown here, it is hard coded into the index.php file, which makes it hard to change. Right now the "footer" module in the administrative backend shows the Joomla copyright and can't be easily edited. It would make much more sense to have a custom (X)HTML module placed in the footer location so the site administrator can more easily change it. If you wanted to create your own footer, you would simply unpublish that module and create a custom html module with whatever language you wanted. In this case we would replace <jdoc:include type="modules" name="footer" style="xhtml" />
with <jdoc:include type="modules" name="bottom" style="xhtml" />
We must also remember to add this position to the templateDetails.xml file. TIP This basic template shows some of the fundamental principles of creating a Joomla template. CSSTemplateTutorialStep2We now have a basic, but functional template. Some simple typography has been added, but more importantly, we have created a pure CSS layout that has dynamic collapsible columns. I have created an installable template that is available from the Compass library: CSSTemplateTutorialStep2.zip Now that we have the basics done, let's create a slightly more attractive template using the techniques we have learned.
This sample content is excerpted from the forthcoming book, titled Joomla! A User's Guide: Building a Joomla! Powered Website, to publish in 2007, by Prentice Hall Professional. Making a Real Joomla 1.5 TemplateThe first thing we need to start with is our comp. A comp is the design that will be the basis of the template. We will be using one kindly donated by Casey Lee, the Lead Designer from Joomlashack14 for our purposes. It's called "Bold," and we can see it in Figure 9.8.
Slicing and DicingThe next step in the process is what is known as slicing. We need to use our graphics program to create small sliced images that can be used in the template. It's important to pay attention to how the elements can resize if needed. (My graphics application of choice is Fireworks, because I find it better suited to web design[md]as opposed to print[md]than Photoshop). Setting Up Module LocationsThis template will have some specific locations for specific modules, slightly different from the standard Joomla installation. To make sure the modules are correctly set up as you work through this template, make sure of the following:
Nothing else should be published in these locations. HeaderThe header image has a faint swish at the top. We want to retain that, so we put the image in as a background and then assign a color also. That way, the header will scale vertically if we need it to, for example, if the font sizes are resized. We also need to change the colors of any type to white so that they will show up on the black background. We also use the background image for the search box. We need to make sure that we target the correct input by using CSS specificity. I have also used absolute positioning inside a relatively positioned element to place the search box where I want it. The image will not scale with text resizing with just a single image. That would require a top and bottom image. That's another exercise for you! #header { #header h1 { #header input { #header .search { I did not use a graphical logo here; I used plain text. The reason is mainly because SEOs, as search engines, cannot read images. One could do some nifty image replacement, but I will leave that as an exercise for you to do on your own. Our header now looks like what's shown in Figure 9.9.
Next, we need to implement a technique used to show a background on a fluid column: sliding doors. Column BackgroundsRecall that when we put a color background on the columns, the color did not extend all the way to the footer. This is because the div element, in this case sidebar and sidebar-2, is only as tall as the content. It does not grow to fill the containing element. We have to use a technique called Sliding Faux Columns, with which you essentially create two wide images that will slide over each other. We need to create two new containers to hold the backgrounds. Normally, we could apply one to the #wrap, but I am using an extra (and wasteful) container for illustration purposes. For a full description, you can check out these two guides:
In our case, our maximum width is 960px, so we start with an image of that width. In the image source files, it is slidingcolumns.png. We then export two slices (I used the same slice and just hid/revealed the side images), one 960px wide with a 192px background on the left, and one 960px wide with a 196px background on the left. NOTE Were does 192px come from? Its 20% of 960, as our columns are 20% wide. #leftfauxcol { #rightfauxcol { In our index.php, we simply added an inner container inside the wrap: <div id="wrap">
<?php if($this->countModules('left')) : ?> <div id="leftfauxcol"> <?php endif; ?> <?php if($this->countModules('right')) : ?> <div id="rightfauxcol"> <?php endif; ?> <div id="header"> We also need to put a conditional on the closing div's: <?php if($this->countModules('left')) : ?>
</div> <!--end of leftfauxcol--> <?php endif; ?> <?php if($this->countModules('right')) : ?> </div> <!--end of rightfauxcol--> <?php endif; ?> We must also put a background onto our footer and bottom modules/elements; otherwise, the column background would be shown: #footer {
background:#212121; color:#fff; text-align:right; clear:both; } #bottom { We need to clear the floats so that the float container (the faux columns) will extend to the bottom of the page. The traditional method to do this was to use the property :after.15 But with the release of IE7, this method will not work completely. We need to address clearing the floats in Internet Explorer 6 and 7, and this is where it all goes down the tubes. A couple of solutions have been found. We are going to use the Float (nearly) Everything option here. Thus, we add a simple clear:both to the #footer, and we add floats to the fauxcol wrappers. We add these to a conditional stylesheet specifically for IE6: #leftfauxcol,#rightfauxcol,#footer {
float:left; width:100%; } We will have to add some conditional statements to the head of the index.php file: <!--[if lte IE 6]>
<link href="/templates/<?php echo $this->template ?>/css/ie6only.css" rel="stylesheet" type="text/css" /> <![endif]--> <!--[if lte IE 7]> <link href="/templates/<?php echo $this->template ?>/css/ie7only.css" rel="stylesheet" type="text/css" /> <![endif]--> Flexible ModulesIn our design, we have a large initial module block. We don't know how tall the text will be that is needed. To solve that problem, we put the module jdoc:include statement in a containing element and give it a background of the same color as the image. This is the same strategy we used for the header: <?php if($this->countModules('top')) : ?>
<div id="top"> <div class="inside"> <jdoc:include type="modules" name="top" style="xhtml" /> </div> </div> <?php else : ?> <div id="top"> </div> <?php endif; ?> Note we have also used a conditional comment so that if the top module location has no content, the orange teaser image will not be there. What will be there is an empty container that will contain a little of the background image and 20px worth of vertical padding. This is purely for aesthetics. The CSS needs to use CSS specificity to override the moduletable styles that have been defined earlier: #top {
background:#ea6800 url(../images/teaser.png) no-repeat; padding:10px; } #top .moduletable h3 { #top .moduletable { Now we need to focus on some of the typography. TypographyMany of the links will need to be white, so we will define them as such globally and then modify the color for the center column: a:link,a:visited { a:hover { #content60 a:link,#content60 a:visited,#content80 a:link,#content80 a:visited,#content100 a:link,#content100 a:visited { The design has a stylized button. We create this using a background image from the comp. It's a thin slice that is tiled horizontally: .button {
border:#000 solid 1px; background:#fff url(../images/buttonbackground.png) repeat-x; height:25px; cursor:hand; margin:4px 0; padding:0 4px; } For tables, such as FAQ, we can add an easy background by repeating the use of the image we used for the teaser. Reusing the image is thematic and also saves on image download, making the pages load faster. sectiontableheader {
background: url('/../images/teaser.png'); color:#fff; font:1.2em bold Arial, Helvetica, sans-serif; padding:5px; } Modules need just a simple redefinition and adjustments to the padding and margins: .moduletable { .moduletable h3 { Menus, as always, need a lot of style CSS. Here, we keep it as simple as possible. We slice a single image that includes both the bullet and the underline. Not that the styling is turned "on" by applying a module suffix of menu to any list of the links that we want this look applied to: .moduletablemenu { .moduletablemenu h3 { .moduletablemenu ul { .moduletablemenu li { .moduletablemenu a:link,.moduletablemenu a:visited { .moduletablemenu a:hover { Last is the Tab menu at the top right. As an accessibility advocate, we want to set this up so that the tabs will scale as the font is resizing. Fortunately, a technique has been developed to do this; it's actually the same principle we use for our columns, the sliding doors again! We will also try and do some speed optimization for the template and use just a single image for the left and right side of the "doors," as well as the on and off state. This is known as using sprites. The CSS is not too hard; we just have to fiddle around with the vertical position of the image background for the on state: .moduletabletabs { .moduletabletabs ul { .moduletabletabs li { .moduletabletabs a:link,.moduletabletabs a:visited { .moduletabletabs #current { .moduletabletabs #current a { We will also need to add the module suffix of tabs to the module for the menu we are using. If you look back at the original design, you will notice that there were icons on these tabs. As we are already using two background images, one on the li and one on the link, we would need a third element on which to place the icon background. You could do this by having a span, but this is advanced CSS Jujutsu. I'll leave that as a homework assignment. The last thing that remains is to revise the templateDetails.xml file. It needs to contain all the files and images used in the template so it will install properly as a zip file. There are a number of tools that will do this automatically for you if you are using 1.0.X, but at the time of writing, none are available for 1.5. Our finished template should look like Figure 9.10.
The Least You Need to Know CSSTemplateTutorialStep3We now have a template based on a comp (or design). Some simple typography has been added, but more importantly, we have created a pure CSS layout that has dynamic collapsible columns and a slick tabbed menu. I have created an installable template that is available from the Compass library: Now that we have the basics done, let's start delving into some of the advanced features possible with 1.5 templates.
This sample content is excerpted from the forthcoming book, titled Joomla! A User's Guide: Building a Joomla! Powered Website, to publish in 2007, by Prentice Hall Professional. Advanced Templating FeaturesJoomla 1.5 offers a number of advanced template features that significantly expand what is possible with templates. We have already seen one example in this chapter, the ability to create custom chrome or output for modules.
Template ParametersNew in 1.5 is the addition of template parameters for templates. This allows you to pass variables to the template from options selected in the administrative backend. We can add a relatively simple parameter function to our template. In the templateDetails.xml file, add the following: <params>
<param name="template_width" type="list" default="fluid" label="Template Width" description="Width style of the template"> <option value="fluid">Fluid with maximum and minimum</option> <option value="medium">Medium</option> <option value="small">Small</option> </param> </params> You will also need a file called params.ini in your template folder. It can be a blank file, but Joomla needs this file to store what settings you have. For example, an INI file for the previous example might look like this: template_width=2
You need to make sure that this file is writable so changes can be made. We will also need to add that as a file in the templateDetails.xml file. In the Template Manager for that template, you will see the settings for the parameter, as shown in Figure 9.11.
We can see that it is a simple drop-down with three options. <param name="template_width" type="radio" default="0" label="Template Width" description="Change width setting of template">
<option value="0">800x600</option> <option value="1">1024x756</option> <option value="2">fluid (min/max with FF and IE7, 80% with IE6)</option> </param> Then we change the body tag in our index.php to the following: <body class="width_<?php echo $this->params->get('template_width'); ?>">
We then add the following to the CSS file: body.width_0 div#wrap { body.width_1 div#wrap { body.width_2 div#wrap { #wrap { This gives us three options: a fixed narrow width, fixed wide width, and a fluid version. Template OverridesPerhaps the most powerful new feature of templates in 1.5 is the ability to easily override core output. This is done with new output files called template files that correspond to the layout views of components and modules. Joomla checks in each case to see if one exists in the template folder, and if there is, uses that one and overrides the normal output. Override StructureAll of the layout views and templates are in the main core in a /tmpl/ folder. The location is slightly different for components as for modules because modules essentially have only one view. For example: modules/mod_newsflash/tmpl/ modules/mod_poll/tmpl/ components/com_login/views/login/tmpl/ components/com_content/views/section/tmpl/
The basic structure of all components and modules is View>Layout>Templates. Table 9.3 shows some examples; note that modules only have one view. Table 9.3
There are usually several template files involved for a particular layout. They have a common naming convention (see Table 9.4). Table 9.4
Overriding ModulesEach module has a new folder that contains its templates, which is called tmpl. Inside are PHP files that create the output. For example: /modules/mod_newsflash/tmpl/default.php
/modules/mod_newsflash/tmpl/horiz.php /modules/mod_newsflash/tmpl/vert.php /modules/mod_newsflash/tmpl/_item.php The first three are the three layouts of Newsflash based on which module options are chosen, and the _item.php file is a common layout template used by all three. Opening that file, we find: <?php // no direct access defined('_JEXEC') or die('Restricted access'); ?> <table class="contentpaneopen<?php echo $params->get( 'moduleclass_sfx' ); ?>"> We could change this to remove the tables to make a little more accessible: <?php // no direct access defined('_JEXEC') or die('Restricted access'); ?> <div class="contentpaneopen<?php echo $params->get( 'moduleclass_sfx' ); ?>"> This new file should be placed in the template directory in a folder called html as follows: templates/templatetutorial15bold/html/mod_newsflash/_item.php
We just took the tables out of the Newsflash module[md]as easy as that! Component OverridesComponents work almost exactly the same way, except there are several views associated with many components. If we look in the com_content folder, we see a folder called views. /components/com_content/views/
/components/com_content/views/archive /components/com_content/views/article /components/com_content/views/category /components/com_content/views/section So these folders would match the four possible views for content, archive, article, category, and section. If we look in the category folder, we see: /components/com_content/views/category/blog.php
/components/com_content/views/category/blog_item.php /components/com_content/views/category/blog_links.php /components/com_content/views/category/default.php /components/com_content/views/category/default_items.php Note that in the case of com_content, the default.php layout is referring to the standard layout that presents articles as a link list. Opening up the blog_item.php file we see the tables currently used. If we want to override the output, we put what we want to use in our template/html/ folder, for example: templates/templatetutorial15bold/html/com_content/category/blog_item.php
It's a relatively simple process to copy and paste all these views from the /components/ and /modules/ folders into the templates/yourtemplate/html folder. The template override functionality provides a powerful mechanism to customize your Joomla site through its template. You can create output templates that focus on SEO, accessibility, or the specific needs of a client. The Least You Need to Know Tableless JoomlaThe Joomla download also contains a template called Beez that is a developed example of the template overrides in action. The Design and Accessibility team have created a full example set of overrides as contained in the html folder. Our final example is a template that uses these overrides to remove all tables from the output of Joomla. CSSTemplateTutorialStep4We now have a template based on a comp (or design). More visual typography has been added, but more importantly, we have used our pure CSS layout to create a template that has dynamic collapsible columns and a slick tabbed menu. We have then overridden the output of Joomla so that no other tables are used. I have created an installable template that is available from the Compass library: CSSTemplateTutorialStep4.zip This sample content is excerpted from the forthcoming book, titled Joomla! A User's Guide: Building a Joomla! Powered Website, to publish in 2007, by Prentice Hall Professional. SummaryIn this chapter, we worked through four examples of templates, each time building the complexity and features.
Links and Resourceswww.upsdell.com |
|||||||||||||||||||||||||||||||||||
| Last Updated on Monday, 07 December 2009 14:01 |