Chapter 3. Coding It Up

We are now ready to take our visual design and make it a reality. We’ll start by continuing the process suggested in Chapter 2 and apply our new design to a copy of the existing rhuk_solarflare_ii template.

We’ll them discuss the importance of semantic XHTML and show you how to create our new design from scratch, eliminating as many tables as possible, and using all XHTML and CSS, for a fast-loading, SEO-friendly template.

First, let’s make sure you’ve got some basics set up to handle a standard workflow for your template creation. You’ll need a hosted or local version of Joomla! and a good HTML editor. Most of you will be using Dreamweaver, which we’ll cover here, although any HTML or text editor that lets you see the line number on the left of the screen would be ideal. If the editor lets you view code in color context for HTML tags, attributes, CSS rules, and PHP function variables and strings, that’s even better!

We will do our best to show you as much as possible through the WYSIWYG and wizard views of the editors, but there are going to be many steps where it will be necessary to edit the PHP code, CSS, and XHTML directly. I’ll be as thorough as possible in these steps to ensure that everyone has a positive experience while hitting the view code or source tab button in their editor of choice.

Note

Need a visual editor equivalent to Dreamweaver or GoLive? We recommend Nvu http://nvu.com or KompoZer http://kompozer.net. KompoZer is a more recent fork from Nvu’s code base and does have some bug fixes in it that Nvu hasn’t released yet. Both Nvu and KompoZer are based on Mozilla’s Composer code base.

Already know the code? Then use a text-based editor like HTML-kit http://www.chami.com/HTML-kit/. HTML-kit is not open-source, but it’s still free and has a large community of plug-in developers, which enables HTML-kit to support several types of validation and all your favorite scripting languages.

Got Joomla!?

First things first! If by some chance you don’t have one yet, you’ll need an installation of Joomla! to work with. You can build your template “blind”, only working locally in your HTML editor. But as you’ll see, we’ll be restricted from pure WYSIWYG work, so we do need a way to see our template in action as it progresses. Also, in some instances we’ll be using Joomla!’s Administration Panel to help place modules and components as well as control how module content is being output.

As we explained in Chapter 1, we assume you’re familiar with Joomla! and its administration basics and have a development installation to work with. If you need help in getting your Joomla! installation up and running, or need an overview of how to use the Joomla! Administration Panel, we highly recommend you to read Packt Publishing’s Building Websites with Joomla! by Matjaz Juric, Sohail Salehi, and Hagen Graf.

Joomla! Servers

For those of you already familiar with Joomla!, we have a couple of standalone Joomla! installs to recommend for template development.

If you don’t have a web server available to you at all, we highly recommend Ravenwood Joomla! Server (formerly called JoomlaLite).

http://extensions.joomla.org/component/option,com_mtree/task,listcats/cat_id,1850/Itemid,35/

Ravenwood Joomla! Server is probably the easiest development installation to get rolling, and it allows you to run Joomla! on your local machine without a web server. In fact, if you have a web server running on your computer, like Apache or IIS, you must disable it (likewise for MySQL) for Ravenwood JS to work properly.

Ravenwood JS is so light that you can even run it from an external flash/USB drive. This enables you to have multiple versions of Joomla! installs for different projects (but you can only run one installation at a time), and take a project with you from computer to computer.

Another alternative is to use JSAS (Joomla! Stand Alone Server). JSAS is somewhat similar to Ravenwood JS, but it’s a bit bigger (and probably won’t fit on a flash drive). However, it lets you have five separate Joomla! sites under one installation.

http://www.joomla.org/content/view/462/37/

Note

Mac users: You will need to rely on an installation of Joomla! on a server, or you can install XAMPP for Mac OSX. Afterwards, you’ll need to run a full installation of Joomla!.

http://www.apachefriends.org/en/xampp-macosx.html

You can also just install PHP and MySQL individually on your Mac, and then install Joomla! again using the handy instructions from macjoomla.com:

http://www.macjoomla.com/articles/joomla/install_joomla_on_your_mac.html

WYSIWYG Editors: What-You-See-Isn’t-Really-What-You-Get

So you are more used to Dreamweaver, GoLive, or some other neat WYSIWYG editor rather than a plain-text editor. Maybe you make your designs in Photoshop or Fireworks and hit the Save for Web feature that outputs your slices into clean, compressed images along with an HTML page. You can then open up that HTML page in your WYSIWYG HTML editor and see everything. You make a few more tweaks, add your page text and maybe some links, hit Save again, and upload your HTML page and image directory to the server. Why can’t we just do that here?

The Joomla! CMS, like all good content management systems (including blog tools), keeps its content completely separate from the design. The menus and text are not anywhere in the template’s page. All the page content, menu items, and module displays are stored in the “ether of cyberspace” known as Joomla!’s MySQL database tables. All the template’s image elements are dealt with in its CSS file (template_css.css).

The average Joomla! index.php template page (if it’s built right) has nothing visual in it, save a few table cells! The design images are not hard coded into the HTML tables as they are when you export a sliced image with an HTML page from Photoshop or GIMP.

This makes working with and developing templates in a WYSIWYG environment quite challenging. Take a look at what the rhuk_solarflare_ii template looks like in the Design view of Dreamweaver:

WYSIWYG Editors: What-You-See-Isn’t-Really-What-You-Get

Figure 3.1 Rhuk template in Dreamweaver’s Design view.

Even when we (temporarily) associate the Rhuk template with its CSS sheet, it’s still not much to look at:

WYSIWYG Editors: What-You-See-Isn’t-Really-What-You-Get

Figure 3.2 Rhuk template in Dreamweaver’s Design view with CSS sheet attached.

Not very helpful visually! You may be thinking: “I’ve heard of Joomla! extensions for HTML editors; maybe one of those is all I need”. Yes, you are right. There are extensions out there to help you with your Joomla! template creation.

You’ll find extensions for Dreamweaver and HTML-kit here:

http://mamboxchange.com/frs/?group_id=106&release_id=1801

There’s also an extension for Nvu here (though, it does appear to be in beta):

http://mamboxchange.com/frs/?group_id=1509

Note

You should be aware that the Joomla! HTML editor extensions basically help you since you do not have to remember specific PHP code for content and module positions.

Even while using extensions, you will be spending the majority of your time in the Code view of the HTML editor, placing your cursor where you want the PHP code for the module position to appear, and then selecting your code of choice from the extension drop-down menu.

Also, most extensions are originally written for Mambo, not Joomla!. While at the moment, they are compatible with Joomla! 1.0.x installs, as time goes, unless someone comes up with an all-Joomla! extension (I’m sure they will, but at this time I couldn’t find one), the module position code may change, rendering your extension useless with future releases of Joomla!.

In the course of this chapter, you won’t need to use an extension as we will be getting very intimate with the template’s header, content, footer, and module position’s PHP code. We strongly recommend that you take this opportunity to learn and understand how these pieces work within the template first.

Once you have a general understanding of what each piece of code will produce, using a Joomla! extension for your editor will streamline your workflow, preventing you from constantly hunting and pecking through your previous template endeavors for code snippits to cut and paste.

Note

Extensions! Make your own code repository. Now that you know the low-down on how template extensions work, any good editor, be it WYSIWYG or text-based, has what’s usually called a “snippits panel” (Sometimes this is just a folder that’s part of your working directory view.) This feature enables you to create a code snippit or page in which you copy and paste your own reusable code or text. The application will remember it forever and keep it readily available for reuse, usually via a single click or key stroke. Some editors will even let you drag-and-drop the code to its rightful place in your template. If you don’t have this feature in your editor, or you just want something robust, you can use inteleXual’s Yankee Clipper III (I personally use it) http://www.intelexual.com/products/YC3/. YC3 isn’t open-source, but it is a free and a very powerful standalone application that you can use with more than just your HTML editor.

Setting Up Your Workflow

Your workflow will pretty much look like the following:

Setting Up Your Workflow

Figure 3.3 Your basic work-flow

You’ll be editing CSS and XHTML in your HTML editor. After each edit, hit Save, then Alt+tab or taskbar over to your browser window, and hit Refresh to check the results. (I would usually direct you to use Alt+tab, but you can use different ways provided you get to the desired window.) Depending on where you are in this process, you might also have two or more browser windows or tabs open: one with your Joomla! template view and others with the various Joomla! Administration Panels that you’re using.

Dreamweaver, Nvu, or a robust text editor like HTML-kit all let you FTP directly via a site panel or set up a working directory panel (if you’re working locally with a standalone server). Be sure to use this feature. It will let you edit and save to the actual index.php file and the template_css.css style sheet without having to stop and copy to your working directory or uploading your file with a standalone FTP client. You will then be able to Alt+tab to a browser and view your results instantly after hitting Save.

Note

Be sure to save regularly and take backups! Backups are sometimes more important than saving. They enable you to roll back to a previously stable version of your design if your XHTML and CSS have stopped playing nice. Rather than continuing to futz with your code, wondering where you broke it, it’s sometimes much more cost-effective to roll back to your last good stopping point and try again. You can set your preferences in some editors, like HTML-kit, to auto save backups for you in a directory of your choice. However, only you know when you’re at a good “Hey, this is great!” spot. When you get to these points, get into the habit of using the Save a Copy feature to take backups. Your future-futzing-self will love you for it.

Firefox: Use It

One more workflow issue before we get to the fun stuff. Note that the browser icon in Figure 3.3 is a Firefox icon. It’s more than a suggestion, or just what I, as a geek prefer. It’s what you should use when developing for the Web, period.

If you don’t like Firefox, then you can temporarily get away with using something else like Opera, or maybe Safari (if you’re on a Mac). But you really should be using Firefox.

Note

Please, do not use Internet Explorer with your template-development process.

I know that you’re thinking that I simply don’t like IE. But this is not the case at all, IE6 can easily slip into what’s called quirks mode, where, for whatever reason, it works more like old IE 5.x browsers and simply does not render CSS quite the same way that all the other W3C-compliant browsers in the world do.

While IE 7 is reportedly going to handle most of these CSS rendering issues, and maybe you are already using IE 7, I’m just not 100 percent convinced, especially as IE 7 will probably still run differently if quirks mode is triggered.

The main reason why I recommend Firefox is because it is truly a designer and developer’s browser. Firefox has great features that we’ll be taking advantage of to help us streamline our development process. In addition to these built-in features, Firefox has a host of extremely useful extensions that I’ll recommend to further enhance your workflow.

The secondary reason to use Firefox is back to IE. Yes, you are thinking “But everyone uses IE and knows about its quirks mode CSS rendering issues, so why not just design for it?” And that is exactly what we’ll be doing.

Why exactly must we design for Firefox first, then IE? Because IE’s quirks are so well-known among web designers and developers, there are tons of well-documented hacks and workarounds for them. However, if you set up your design only viewing it so that it looks good in IE first, and then check it out in Firefox and other browsers to find it a mess, wrangling with your CSS rules at that point will be much more difficult. Think: driving backwards with no back window or side mirrors in a snow storm.

It will be much easier for you if you develop for Firefox first with valid XHTML and CSS code. The ideal scenario will be that your markup will remain valid and not trigger IE’s quirks mode, saving you a lot of CSS problems. However, if for some reason, your template triggers quirks mode in IE, then you’ll still be able to go in and sparingly apply a well-documented hack or workaround here and there to compensate for IE’s quirks-mode-related box-model issues, pixel drift, and all the other common rendering anomalies known to IE and its quirks mode. The end result will be a valid template that looks great in all browsers.

In a nutshell, there’s no need to view usage of Firefox as part of picking sides in the “Microsoft vs. the World” saga. Firefox is just another good development tool, like your image editor, HTML editor, checklists, and FTP client. When you’re not developing, you can use whatever browser you prefer.

Let’s Make a Template

We’re going to continue leveraging the rhuk_solarflare_ii template. Open your HTML editor, and set it up to display a FTP or local working directory panel so that you have access to your Joomla! installation files. Also, have a couple of browser windows or tabs open with your Joomla! home page loaded into them as well as having the Joomla! Administration Panel available.

Note

Tabs: Use them. They’re one of those neat built-in Firefox features I was talking about. Keep all your Joomla! development and administrator views in one window. Each tab within a Firefox window is accessible via Ctrl+1, Ctrl+2, ... keystrokes. It makes for a much cleaner workspace, especially because we will already be in constant Alt+tab flip mode. Flipping to the wrong browser windows gets annoying and slows you down. You will quickly get in the habit of using “Alt+tab or Ctrl+number?” to jump right to your Joomla! template, your Joomla! Administration page, and so on.

To get started, we’ll create a copy of the existing Rhuk template. I’m using a development installation of Joomla! on a remote server via FTP. If you’re working locally, you can follow my instructions using common desktop commands instead of an FTP client.

  1. Inside your Joomla! installation, locate the template directory and make a copy of the rhuk_solarflare_ii directory. Save this to your desktop or local working directory. (I’ve blurred out the files sitting on my desktop so that they don’t distract you.)

  2. Rename the copy of the directory to a template name that suits your project (and copy it back to the server if working remotely). You’ll see in Figure 3.4, I’ve renamed my directory: my_nature_design and I’m uploading it to my Joomla! templates directory.

    Let’s Make a Template

    Figure 3.4 Renaming the Rhuk template

  3. Use Alt+tab to go over to your Joomla! Administration Panel and look at the Template Manager view. Go to Site | Template Manager | Site Templates. You’ll notice that there are now two rhuk_solarflare_ii templates displayed.

    Let’s Make a Template

    Figure 3.5 Admin panel

  4. Use Alt+tab to go over to your HTML editor and open the templateDetails.xml file from inside the new template directory. At the top of the page, between the opening and closing name tags, write in the new name of your template design. This should be the exact same name you already named the directory my_nature_design. If you want, you can update the other basic information in the XML file, but the name tag change is all that is required at this time. Hit Save. Our code in the templateDetails.xml file looks like this:

    <name>my_nature_design</name>
  5. Alt+tab over to the Template Manger view, and hit Refresh. You will see the copy of the Rhuk template, now has your new name displayed in the Template Manager view.

    Let’s Make a Template

    Figure 3.6 Admin Panel with the new template

  6. Select the new template’s radio button and use the Template Manager view’s Default and Assign buttons (in the upper-right corner) to make your new copy the default, assigned template to Joomla!. After clicking the Default button, you should click the Assign button. This will assign all the pages of your new template (just select them all for now). Then click the Save icon.

    There’s one more step needed to make sure our new template copy is ready to go.

  7. In your HTML editor, open the index.php file. You will have to look at it in Code view. Note that, approximately on the 43rd line, you will need to replace the rhuk_solarflare_ii directory name with the new directory name you gave your template right before the template_css.css name. This ensures the template is referencing the new style sheet. The href code should look like the following:

    <?php echo $mosConfig_live_site;?>
    /templates/your_new_template_name/css/template_css.css

Making Changes to Your New Template

Now that our template base is ready, let’s make a dramatic change to it. Our first change will actually be through the Joomla! Administration Panel. We already know that we’re going to be moving the main navigation buttons from the left module position slot to the top module position slot.

  1. Login and select Modules | Site Modules. You will then be in the Module Manager screen.

  2. Scroll down and click Main Menu. You’ll then be in the Site Module: Edit [Main Menu] screen.

    Making Changes to Your New Template

    Figure 3.7 Site Module Screen

  3. Click the No radio button next to Show Title. We want to turn off the title for this module in our design, as we’re pretty sure people will understand it’s the main menu.

  4. Select top from the drop-down list next to Position.

  5. Select Apply from the top menu.

  6. Use Alt+tab to go over to your browser template view, and then Refresh. Your layout should now look something like the following:

    Making Changes to Your New Template

    Figure 3.8 First look at your Joomla Template Layout

    So far so good! You can see, however, that the height of the top module position doesn’t allow all our navigation buttons to show up. Let’s fix that. Here’s where Firefox comes in handy. We will be using the DOM Source of Selection inspector (that’s one of the HTML views of the web page available in Firefox) to find out what CSS rule is affecting the top module’s height.

  7. Use Alt+tab to go over to your Joomla! template view, and select the text of the available main menu buttons. Make sure that you select some text above and/or below the main menu buttons. This will ensure that you capture all the relevant tags to the menu.

  8. Right-click and select View Selection Source. This will open up a window that lets you see Firefox’s DOM Source of Selection inspector for just the items you’ve selected.

    Making Changes to Your New Template

    Figure 3.9 Selecting View Selection Source

  9. View the DOM Source of Selection, and locate the main menu items. (If you find the code confusing to look at, just press Ctrl+F to find the menu items Home or New Stuff. This will put you in the right area of the code and then just look a few lines up from Home.)

    Making Changes to Your New Template

    Figure 3.10 Viewing the DOM

  10. Note that, just above the table where the main menu items start, there are two div ids and one class reference that is affecting our top module position layout. It is likely that one of these ids or the class rule is what’s affecting our top module position height. Again, just as in Chapter 2, you’ll find it very useful to have a scratch text pad open so that you can make checklists and notes.

  11. Copy down the two id names top_outer, top_inner and the class name: moduletable somewhere where you will be able to easily reference them later.

We’re now ready to take a look at the template_css.css style sheet. If you’re familiar with CSS rule syntax, go ahead and open up the template_css.css from inside the CSS directory into your HTML editor. It should open right into Code or Source view. If not, make sure you’re in Code view so that you can see all the rules.

If you’re more comfortable using your HTML editor’s CSS Wizard, we recommend that you float the CSS styles panel and CSS properties panel next to each other in Dreamweaver so that each rule that you click on in the styles panel will appear next to it in the properties panel as I’ve done in Figure 3.11.

Making Changes to Your New Template

Figure 3.11 Editing your CSS file

Note

Try to use the Code view Overall, I recommend that as much as possible, you should go ahead and work directly in the style sheet’s Code view. The wizard views are a good way to see what’s going on in your style sheet, and the Properties panel can help jog your memory for the syntax and spellings of various CSS properties. But if you know that you’re just going to change a hex color, or a pixel height or width, go ahead and look directly at the CSS sheet in the Code view. Otherwise, you may accidentally add or delete properties. Sometimes even accidentally adding blank properties in a rule can detrimentally affect the layout’s outcome, depending on how the rule is applied. Dreamweaver and many other CSS wizards will let you right-click on a selected rule in the Styles panel and Go to the Code or View Code, effectively taking you right to the correct spot in the Code view of the style sheet. This is a good way to become more familiar with your style sheets through the CSS wizard, while ensuring that all your edits are the intended ones and are done directly in the Code view.

Looking at our style sheet or in the Style panel, let’s find those two ids and class names and have a look at them.

It’s just a good design practice to name CSS rules that affect only a particular module position with that module position’s name. You will speed your workflow and be much less confused in the long run. It’s clear that the Rhuk template designer followed this practice, so it’s clear that the moduletable class is not what we’re looking for. We want to edit one of the top_outer or top_inner classes.

The Difference between CSS Classes and IDs

In general, classes are not used to denote position, height, width, or other main features of module positions. (Classes have a “.” before their name in a style sheet and can be reused by many different XHTML elements on a page using the class attribute.) Because each module position should be unique within your template, you will only ever have one top module, one left module, one right module and so on, so it makes sense to use only ids to control module positions. (Ids have a “#” before their name and can only be assigned to one XHTML object on the page using the id attribute.)

Since we’re looking to change the height of the top module, it’s pretty clear that either the top_outer or top_inner ids is where we need to look because they have got the word top in their name, and they are ids, not classes.

Let’s look at the first id rule: top_outer. It turns out that top_outer only has two properties associated with it, and neither of them are the height property. So let’s look at top_inner.It is set to a height of 144px.

The Difference between CSS Classes and IDs

Figure 3.12 Editing the top_inner rule

That’s what the Properties panel shows. If we look in the actual style sheet using the Code view, we see that top_inner actually has two height properties! (This is another good reason for trying to work inside the Code view as much as possible.) The second height property has a value of 150px. The Rhuk template author has added the !important property value as a hack after the first height property, so the layout will render well in Firefox and IE.

Note

!important They don’t call them Cascading Style Sheets for nothing! Using the !imporant property value is one of the most common ways to hack IE. Normally, whatever rule is last specified in a style sheet takes precedence. Hence, the style sheet cascades. However, if you use !important after a property value, then that CSS property will take precedence regardless of what appears after it. This is true for all browsers except IE, which completely ignores it. If IE has fallen into quirks mode, borders, margins, and padding property values, will start to get off compared to Firefox. (We’ll look at the box model that describes this in detail in Chapter 4, Debugging and Validation.) If your height property looks good at 144px in Firefox, but needs to be set to 150px to accommodate IE’s issues, then you can see how setting a Firefox height property first with a !important value will make it look good in Firefox and other compliant browsers while IE ignores it and picks up the last height value, looking great at 150px.

Checking our design mock-up in our image editor, we can see that we will need about 250 pixels to accommodate our main menu’s height. We can also see, based on the Rhuk’s design, that there must be about a six pixel difference between Firefox and IE due to some other margins or padding. So let’s enter 250px into the first height property with the !important value and enter 256px into the second height property. The code should look like this:

#top_inner {
    padding: 2px;
    height: 250px !important;
    height: 256px;
    overflow: hidden;
    float: none !important;
    float: left;
}

Hit Save, use Alt-tab to go over to your template’s browser view, and Refresh.

The Difference between CSS Classes and IDs

Figure 3.13 Checking the menu height

This is looking good. All the menu items are visible and the padding is consistent. (This would be one of those ideal moments to save a backup!)

At this point, I’ll assume based on my previous explanation and images, that you understand how to use Firefox’s DOM Source of Selection inspector to locate the id and class names of XHTML elements that you’d like to manipulate via their CSS rules.

From here on in this chapter, I’ll just reference the id or class name that we’re changing and not drag you through its location finding process. I’ll also assume that you will be working with your CSS sheet the way you’re most comfortable. Just be aware that, if you’re working in the CSS wizard view, you may inadvertently add or remove code or miss hacks and workarounds added by the Rhuk author.

Changing Our Template Colors

Remember all those lists we made in Chapter 2? They will be coming in handy. Open up your color palette text file and have it ready. We’re going to start changing the colors in our template.

  1. Use Alt+tab to go over to your HTML editor viewing your CSS sheet.

  2. Find the outline id rule in the style sheet and change the background property to your main content area background color. In our case, it’s #e3dabd. It should look like the following:

    outline {
        border: 1px solid #586230;
        background: #e3dabd;
        padding: 2px;
    }
  3. Use Alt+tab to go over to your template browser, hit Refresh, and check. The inner table areas of the content should be the light-beige, #e3dabd color.

  4. Find the body rule in the template_css.css style sheet, and add the background property to it. Place in your color palette’s main background color. Our background color is #070706. It should look like the following:

    body {
        height: 100%;
        margin-bottom: 1px;
        background: #070706;
    }
  5. Use Alt+tab to go over to your template browser, Refresh, and check:

    Changing Our Template Colors

    Figure 3.14 Checking the background property

Whoops! Something has gone wrong. Our background color didn’t change when we added the background property. Look at the style sheet again and notice that there are two body element rules. (The second body rule appears at line 323!) We’re not sure why the Rhuk author did that. Let’s consolidate these two body element rules.

  1. Find the last body rule at about line 323 in the template_css.css style sheet, select and copy it’s properties, and then delete the rule.

  2. Move up to the first body rule and paste the new properties under the existing ones. You will now have two height properties set to 100%. You can delete one of them.

  3. Move the margin-bottom property underneath the margin property. Again, the last property wins, so the 15 pixel “all margins” property would overwrite the 1 pixel margin-bottom property.

  4. Change the background color to your color pallet’s main background color. (Again ours is #070706.) You should now have a single body rule at line 7 of the template_css.css sheet that looks like the following:

    body {
       height: 100%;
       margin: 15px;
       margin-bottom: 1px;
       padding: 0px;
       font-family: Arial, Helvetica, Sans Serif;
       line-height: 120%;
       font-size: 11px;
       color: #333333;
       background: #070706;
    }
  5. Use Alt+tab to go over to your template browser view and check:

    Changing Our Template Colors

    Figure 3.15 Checking the background property again

    OK, looks good. Let’s continue changing the colors. After each id change, we will assume you’re Alt+tabbing and checking the results in your browser. We will continue using our colors, fonts, and pixel spacing but feel free to interchange any property value we denote with a property value that matches your own template design.

  6. Add the background property to the buttons_inner rule and set it to #586230.

  7. Change the border property color on the outline rule to #586230.

For our template design, we want to get rid of almost all the grey outlines separating each module position. The only outlines we’d like to keep are the outlines surrounding the Login, Back, Vote, and Result-type buttons. We can see several rules touting the same border: 1px solid #cccccc; property.

We will press Ctrl+F and use our HTML editor’s “find” feature to zero in on each border property with those values and see, one by one, if they’re something we want to remove, or change the color to the dark green of our color scheme.

Changing Our Template Colors

Figure 3.16 Checking the border change

Now that we’ve removed each of the unwanted outlines, let’s move on to the final rollover colors and fonts.

  1. Find the ul#mainlevel-nav li a:hover rule. Change the background property color to #e3dabd. This fixes the rollover on the top menu.

  2. Change the color property of the ul#mainlevel-nav li a:hover rule to #e3dabd and add a font-family property of Trebuchet MS, Helvetica, Arial to it as well.

  3. Change the color property of the ul#mainlevel-nav li a:hover rule to #586230. This makes the fonts and rollover colors of the top menu work with our color scheme.

  4. Find the a:link, a:visited rule. Change the color property to #586230.

  5. Find the a:hover rule. Change the color property to #918B73.

  6. Add a font-family property of Trebuchet MS, Helvetica, Arial to the contentheading rule. Then change the color to #586230.

  7. Add a font-family property of Trebuchet MS, Helvetica, Arial to the table.moduletable th, div.moduletable h3 rule. Then change the color to #586230. Increase the font-size property to 12.

    Changing Our Template Colors

    Figure 3.17 Checking the fonts

Changing and Adding New Images to Our Template

Now we’re ready to add our images. In Chapter 2, we were careful to export most of our images using the same name and image type as the images in the Rhuk template. The only image to which we gave a unique name was our header image. For the most part, we should just be able to upload (or copy if working locally) our images into our new template’s image directory and let them overwrite the existing Rhuk images.

While you do this, press Alt+tab and Refresh to check your template.

Changing and Adding New Images to Our Template

Figure 3.18 Checking the images

The final images that we need to add are, of course, in the main header. We’d also like the top navigation to be textured and lastly, we’d like our main background to have a gradient.

Top Navigation Images

Let’s start with the top navigation. The textured background is actually just the subhead background. Locate the #buttons_inner rule and add a background-image property set to: url(../images/subhead_bg.png).

Next, we want to put our faded background in. We want to ensure that the largest screen size can accommodate the gradient, so we’ve set it for a width of 4 pixels and a height of 1024 pixels.

Now surely many people will have screens much larger than this. That is why the main background color (#070706) is set to the bottommost color of the gradient. We will set our gradient to repeat from the top, left corner on the horizontal axis only and not to scroll. On screens larger than 1024 pixels high, the background color will stop, and the natural background color will pick up and go to infinity. This uses less bandwidth as we can use a smaller image instead of creating one that is much larger.

Locate the body rule and add the following values to the background property after the background color:

url(../images/main_bg.jpg) repeat-x fixed top left

The complete rule should now look like the following:

body {
    height: 100%;
    margin: 15px;
    margin-bottom: 1px;
    padding: 0px;
    font-family: Arial, Helvetica, Sans Serif;
    line-height: 120%;
    font-size: 11px;
    color: #333333;
    background: #070706 url(../images/main_bg.jpg) repeat-x fixed top
                                                                left;
}

Click Save, use Alt+tab to go over to your browser and Refresh to view your results.

Top Navigation Images

Figure 3.19 Checking the top navigation and background images

The Header Image

The background looks good. We last named our header my_nature_header.jpg. You probably noticed while working with the style sheet, that there were two header rules: header_outer and header. The header rule uses a background property with a url value. Let’s replace the existing header image name with our header image name in that url property value. The rule should look like the following:

#header {
    float: left;
    padding: 0px;
    margin-right: 2px;
    width: 635px;
    height: 250px;
     background: url(../images/my_nature_header.jpg) no-repeat;
}

Click Save, use Alt+tab to go over to your browser, and Refresh to view your results.

The Header Image

Figure 3.20 Checking the header

Well, it looks like we have just one last tweak to make. The header rule’s height property is set to 150px. Our header image was designed to match our main menu height, so let’s change the height property to 250px. Now, use Alt+tab, and Refresh to check your template.

The Header Image

Figure 3.21 Checking the header again

Congratulation! You now have your completed Joomla! template. If you’d like to compare your final template_css.css style sheet with the one that I came up with for this design, refer to the Rhuk Redesign section in the Appendix.

You will notice that we did all this without even touching the original template’s XHTML in the index.php file! You will not always be so lucky. Let’s now look at what’s required to design your own XHTML layout from scratch.

The Truth about XHTML

We now have a working template of our design and that’s great. Now, let’s take it a step further.

You might have heard the word semantic used in conjunction with websites. A semantic site is simply a website whose presentation is completely separated from its content whose content is presented in a logical order of importance using only XHTML markup to define the type of content and data displayed.

This requires a structured organization of heading tags and the proper use of informational XHTML tags such as label, address, cite, and dt. This helps in informing browsers, other web applications, and code viewers what the content actually is.

A key distinction of a purely semantic site is the use of tables only to properly display tabular data and never to hold the layout of a web page together. The use of presentational HTML tags such as bold or strong, italics or em, etc. is eliminated because the layout and presentation of a semantic site are entirely controlled via the site’s CSS file and never by any of its XHTML markup. Both, the site’s XHTML markup and its CSS need to adhere to the web standards provided by the W3C (World Wide Web Consortium).

We’ve previously discussed in detail that this separation of content from layout is exactly what Joomla! does (and hence it’s so hard to code with a WYSIWYG editor), but as you can see, there’s a bit more to being semantic than just this separation. In the end, a Joomla! site is only as semantic and standard compliant as its template designer cares to make it.

While we would love to come up with a purely semantic, valid template, there are some limitations when working with Joomla! which prevent this. Most of these aren’t really limitations when compared to the limitations placed on the features of Joomla! by the use of purely semantic requirements. So we’ll make some reasonable compromises and apply consistent web standards to our template with a semantic-as-possible layout.

By having this as our goal, our Joomla! template will generally be less bandwidth intense, easier to maintain, accessible, and cross-compatible with as many current browsers as possible including new browsers, browsers that cater to users with disabilities as well as search engine bots, and some mobile formats.

Note

Still pondering what semantic is? CSS Zen Garden is one of best examples of a semantic website in action: http://csszengarden.com. This site shows how the same semantic XHTML can be beautifully designed in dramatically different ways using CSS. The resulting pages look different, but all have the exact same core content. It’s a great site to look through and you will probably find many inspiring designs and applications of CSS you never dreamed of.

Now that we’ve learned a little about semantic layout and we have a few goals for our newest Joomla! template, we’re going to approximate the same visual design that we applied to the Rhuk template, but we’re going to make sure that the content loads in a bit more semantically.

This means that the main content shows up before the sidebar information so that text readers, mobile devices, and search engine bots will understand our content better. We’re also going to get as much module content as possible to output without tables. (We can’t control some module content.) We will do all of this with a style sheet that’s concise and easy to understand, and both our XHTML and CSS will validate to W3C web standards.

As a result of some of these self-imposed restrictions, our final visual design will be varied slightly from our table-based layout, but it will still be a great design. Let’s get started!

Note

New to XHTML, CSS, and Web Standards? AlistApart has an inspiring article: How to Grok Web Standards: http://www.alistapart.com/articles/grokwebstandards. W3schools.com has great tutorial references, which can introduce you to the exact ins and outs of XHTML and CSS (and just about anything else web-related!). Find out all about XHTML: http://w3schools.com/xhtml/default.asp. You can learn about the World Wide Web Consortium’s standards, projects, and various validation tools here: http://www.w3.org.

Tabula Rasa

As before, you will need a development base. We are going to start off with a copy of our brand new template (because we’re going to reuse a lot of the same images), give the directory a new name. Before we FTP it back, open up the index.php file and the template_css.css file. Select All and delete everything in both the files. Just do it! It will be OK.

Now, you will also want to open up that templateDetails.xml file and change the content in the name tag to something that you will recognize in your Joomla! Administration Panel.

If you’re not working locally, FTP the directory into Joomla!’s template folder, and then Alt+tab over to your browser’s Joomla! Administration Panel to ensure that the new template base is there.

Tabula Rasa

Figure 3.22 Your new template base

Set your new template as the default, assigned to all pages, as we did before with the other template and hit Save. You can test this by refreshing your template browser view where you should see nothing!

Tabula Rasa

Figure 3.23 Your first template view

The DOCTYPE

In case you haven’t been paying attention, we’re going to be using XHTML, and for that, there are two common DOCTYPES: Strict and Transitional.

The Strict DOCTYPE is for the truly semantic, it means that you have absolutely no presentational markup in your XHTML. Every element in your XHTML merely aids in describing the type of text and data displayed and all your presentation styles come from your style sheet.

The Transitional DOCTYPE requires you to use the syntax of XHTML (with lower case tags and attribute names, all tags closed, including empty tags, and so on), but your template will not completely break if you reference a presentational HTML tag or other HTML 4.0 attributes in your markup.

Normally, we’d prefer the Strict DOCTYPE. However, at this time, it’s hard to control everything that Joomla! outputs. (Some modules don’t use heading tags for their titles, others output tables natively, and so on.) Also, there’s the ultimate consideration when using Joomla!—the built-in WYSIWYG content editor.

Once your template is part of a working Joomla! site, the key feature that users are most likely going to be interested in leveraging is this WYSIWYG content editor. The use of the WYSIWYG editor to contribute content means that the site will be relying on basic HTML presentational tags (strong, em, strike, u tags, and the like) to format and display text.

As a result, we should not use the XHTML Strict DOCTYPE and instead rely on the XHTML Transitional DOCTYPE. This DOCTYPE will let us take advantage of HTML’s presentational features within our XHTML.

Note

About the TinyMCE WYSIWYG editor: Joomla! uses the TinyMCE WYSIWYG editor from Moxiecode Systems: http://tinymce.moxiecode.com. While this editor does display the CSS styles available to the template and it should be possible to block any tags that would be invalid to your DOCTYPE, keep in mind, that it would require some PHP back-end work in Joomla!. You’d also have to train the content contributors to understand what they can and can’t do in the editor, including what CSS styles they should use to achieve certain kinds of formatting. The other option is to turn off the TinyMCE editor and force the contributors to use only plain text fields, entering semantic XHTML tags manually for their content. For the most part, this is exactly the kind of learning curve most organizations are trying to avoid. The promise of a visual editor that is reminiscent of their favorite word-processing program relieves that learning curve and is probably a big reason why they committed to using Joomla! in the first place. As a result, it’s just better to use the XHTML Transitional DOCTYPE rather than limiting any of the key features of the Joomla! CMS for the sake of pure semantic markup.

Your DOCTYPE will be the first line of code in your index.php file and should look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

You should note, while being integral to a valid template, the DOCTYPE declaration itself is not a part of the XHTML document or an XHTML element. It does not use a closing tag, even though it does look a bit like an empty XHTML tag.

Note

Attention Nvu and other WYSIWYG users: Chances are your WYSIWYG editor automatically placed a DOCTYPE and the required html, header, title, and body tags into your document when you opened your blank index.php file. That’s great, but please go into your editor’s preferences (Tools | Preferences | Advanced in Nvu) and make sure your Markup and DTD preferences are set to XHTML and Transitional. Nvu and possibly other editors will overwrite the DOCTYPE to whatever the preferences are set to if you switch between the Normal (a.k.a. Design) and Source (a.k.a. Code) views. Dreamweaver doesn’t seem to have this problem, but you should set your DOCTYPE preferences there as well just to be safe.

The Main Body

After the DOCTYPE, we can add in the other essential requirements of XHTML Transitional markup which are as follows:

<html>
<head>
<title>My New Template Title</title>
</head>
<body> body parts go here </body>
</html>

You can hit Save, and then Alt+tab and hit Refresh to check it out in your browser.

The Main Body

Figure 3.24 Getting something to show up

Getting the Layout Started

We are moving along in the right direction, but it’s still not much to look at. So let’s get the layout started. We’d like our template to have a standard header that stretches across all three columns. The middle column is the main content holder, and a footer running across the bottom of all three columns must fall beneath the longest extending column. Our basic layout will generally look something like the following:

Getting the Layout Started

Figure 3.25 Checking the fonts

Let’s start off with some very basic XHTML code within the index.php files body tags. This will create the div tags for each segment: header, footer, side columns, and middle/main column:

<body>
<!--<a name="top"></a>-->
<div id="container"><!--container goes here-->
<div id="header">
header stuff goes here:
</div><!--//header-->
<!-- Begin #container2 this holds the content and sidebars-->
<div id="container2">
<!-- Begin #container3 keeps the left col and body positioned-->
<div id="container3">
<!-- Begin #content -->
<div id="content">
main content goes here
</div><!-- //content -->
<!-- #left sidebar -->
<div id="sidebarLT">
left side bar
</div><!--//sidebarLT  -->
</div><!--//container3-->
<!-- #right sidebar -->
<div id="sidebarRT">
right side bar (will include main menu)
</div><!--//sidebarRT -->
</div><!--//container2-->
<div id="top_navlist">
top nav will go here (css will place it up top)
</div><!--//top_navlist-->
<div id="footer">
footer information will go here
</div><!--//footer-->
</div><!--//container-->
</body>

Next, hit Save, use Alt+tab to get to your browser, and Refresh to view the following:

Getting the Layout Started

Figure 3.26 The semantic structure

Still not much to look at, but you can see our semantic goals at work. For instance, if a search engine bot or someone using a text-only browser or mobile device came and viewed our site, this is the semantic order they would see things in:

  • Header: It’s good to know whose stuff you’re looking at.

  • Main content: Here we can get right to the point of what we’re looking for.

  • Left column content: It is under the main content and should have the next most interesting items, news, login, and so on.

  • Right column content: This would include the main menu. (It’s best to push consistent navigation items down towards the bottom of the page so that they don’t clutter up the content. Later on, we can make it easy for a text-only user to navigate down to that main menu with an anchor tag.)

  • Footer information: As we’ve been scrolling down for so long, we have probably forgotten whose site we’re on.

Note

Moving navigation to the bottom: Some SEO experts believe another reason to semantically push the navigation items down the page as far as possible is that it encourages search engine bots to crawl and index more of the page before wandering off down the first link it comes to. The more content the bot can index at a time, the sooner you will be displayed on the search engine. Apparently, it can take months before a site is fully indexed, depending on its size. I have no idea if this is actually true, but its in line with my semantic structure based on usability, so no harm done. You will have to tell me if you think your content is getting better SE coverage based on this structure.

Let’s now start to get this stuff looking like a website. You will notice each of our divs has an id name, and the divs that are going to be our three columns are wrapped inside an outer div called container2.

The main and left columns are wrapped in a div called container3. The entire set of divs including the header and footer, which are outside the container2 div are wrapped in a main div called container.

This structure is going to hold our modules together and let them display semantically with the main content first, but the style will allow the left column to show up on the far left. This structure also ensures that the footer floats to the bottom of the longest column.

First, we will need to add a line of code to get our index page to associate with our CSS template and then be on our way. Place this code inside your header tags, under your title tags (starting at about line 7 in your index.php file):

<script type="text/javascript"> </script>
<style type="text/css" media="screen">
    @import url("<?php echo $mosConfig_live_site;?>
                  /templates/my_nature_design/css/template_css.css");
</style>

We’re going to use the @import method to hide our style sheet from very old browsers such as Netscape 4. The empty JavaScript tag will keep our template from flickering unstyled content before loading in the style sheet.

Our basic CSS in the template_css.css file, which will position our XHTML div tags looks like the following:

/* css */
/*////////// GENERAL //////////*/
    body {
      margin-top: 0px;
      margin-bottom: 30px;
      background-color: #FFFFFF;
    }
    #container {
      width: 850px;
      margin: 0 auto;
        margin-top: 20px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 11px;
      color: #666666;
        background-color: #fff;
        border: 1px solid #333;
    }
    #container2 {
      width: 850px;
      margin: 0 auto;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 11px;
      line-height: 1.6em;
      color: #666666;
        border:1px solid #ff00cc;
    }
    #container3 {
      width: 635px;
        float: left;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 11px;
      line-height: 1.6em;
      color: #666666;
        border:1px solid #ff66cc;
    }
/*////////// HEADERS //////////*/
    #header {
      width: 850px;
        height: 140px;
      border: 1px solid #ff6600;
      padding-bottom: 10px;
      padding-top: 10px;
      clear: both;
    }
/*////////// CONTENT //////////*/
    #content {
      width: 400px;
      padding-left: 10px;
      padding-right: 10px;
      padding-top: 10px;
        border: 1px solid #006600;
        float: right;
    }
/*////////// NAV //////////*/
/*this is the tab layout*/
    #top_navlist {
      position: absolute;
      top: 20px;
     width:850px;
     line-height:normal;
      clear: both;
      border: 1px solid #006600;
    }
/*////////// RIGHT SIDEBAR //////////*/
    #sidebarRT {
      float: right;
      width: 175px;
      padding-left: 21px;
      padding-right: 10px;
      padding-top: 10px;
      border: 1px solid #000066;
    }
/*////////// LEFT SIDEBAR //////////*/
    #sidebarLT {
        float: left;
      width: 175px;
      padding-left: 21px;
      padding-right: 10px;
      padding-top: 10px;
        border: 1px solid #00ff66;
    }
/*////////// FOOTER //////////*/
    #footer {
      margin-top: 15px;
      padding-top: 0px;
      padding-bottom:0px;
      clear: both;
      width: 850px;
      background-color:#FFF;
        border: 1px solid #ff0066;
}

By hitting Save, Alt+tab, and Refresh, the resulting CSS gives us a general layout template that looks like the following:

Getting the Layout Started

Figure 3.27 First look at the layout

Adding Joomla! Modules and Content

At last, we’ve got something that’s starting to look like a website, and we’re ready to start adding Joomla! template code.

First off, Joomla! needs a little information to ensure that everything is running properly, and we need to add this code before the DOCTYPE (right at line 1 of your index.php file):

<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location
                                               is not allowed.' ); ?>

This ensures that the template is being accessed via Joomla! itself (a.k.a. someone just normally hitting the website in the normal way) and that someone hasn’t figured out the direct path to the template file and is trying to access it directly. If all is well, this code will do nothing (which is good because browsers, especially IE really hate it when you put something above the DOCTYPE). Otherwise, the viewer will simply see a Direct Access to this location is not allowed message.

Next, to keep in line with web standard requirements, let’s modify our opening html tag with the following highlighted code, which will ensure that the language settings we chose in the Joomla! Administration Panel’s Global Configuration Settings will be set in our template:

<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo _LANGUAGE;
?>" xml:lang="<?php echo _LANGUAGE; ?>" >

Now, we’re ready for our template’s first meta-tag and to set up the header so that it will dynamically display our template’s title in its self-generated title tag:

Place the highlighted code inside your header tag, replacing your existing title tag, which is just before your style sheet reference link tag:

<head>
<meta http-equiv="Content-Type" content="text/html;
                                              <?php echo _ISO; ?>" />
<?php
if ($my->id) { initEditor(); } ?>
<?php mosShowHead(); ?>
<script type="text/javascript"> </script>
<style type="text/css" media="screen">
    @import url("<?php echo $mosConfig_live_site;?> /templates/
                         my_NEW_nature_design/css/template_css.css");
</style>

Again, after adding each chunk of code save your index.php file, and then press Alt+tab and Refresh to check the site in Firefox, even if you think there’s not much to look at!

You should now see the browser’s window displaying the title of your Joomla! site. If you right-click and View Source on the page, you’ll see that the page is now generating a plethora of standard meta-tags with relevant keyword and description content based on what was paced into the CMS. (This example is based on the View Source for my template only, yours will be different.)

<title>eternalurbanyouth.com aka: tessaract.info - Newsflash
                                                            3</title>
<meta name="title" content="Newsflash 3" />
<meta name="author" content="Administrator" />
<meta name="description" content="Joomla - the dynamic portal engine
                                    and content management system" />
<meta name="keywords" content="Joomla, joomla" />
<meta name="Generator" content="Joomla! - Copyright (C) 2005 Open
                             Source Matters. All rights reserved." />
<meta name="robots" content="index, follow" />
<link rel="shortcut icon" />

We’re now ready to add the actual content modules!

While reviewing our redesigned Rhuk template (a.k.a. my_nature_design), we noted the modules used in our site. After placing the module code in the index.php template, each module name gets wrapped in PHP code that looks like this:

<?php mosLoadModules ('module_name'), ?>

This means that the following mosLoadModules() codes need to be placed inside our div holders in our index.php template:

  • <?php mosLoadModules('user4'), ?>

  • <?php mosLoadModules('left'),?>

  • <?php mosLoadModules('right'),?>

  • <?php mosLoadModules('top'),?>

  • <?php mosLoadModules('user1'),?>

  • <?php mosLoadModules('user2'),?>

  • <?php mosLoadModules('user3'), ?>

The following list contains key content items are needed by our template; these are not modules and therefore, have their own special syntax:

  • Displays the full name of the site:

    <?php echo $mosConfig_sitename; ?>
  • Displays the breadcrumb trail:

    <?php mospathway() ?>
  • Displays the actual body content:

    <?php mosMainBody(); ?>
  • Displays the footer information:

    <?php include_once($mosConfig_absolute_path .'/includes/
    footer.php'),?>

After placing each mosLoadModules() code and key content items into our template, our XHTML will now display information and content entered into the Joomla! CMS via the Joomla! Administration Panel. Your XHTML and PHP should look like this:

<body>
<div id="container"><!--container goes here-->
<div id="header">
header stuff goes here:
<?php echo $mosConfig_sitename; ?>
<?php mosLoadModules ( 'user4', -2 ); ?>
</div><!--//header-->
<!-- Begin #container2 this holds the content and sidebars-->
<div id="container2">
<!-- Begin #container3 keeps the left col and body positioned-->
<div id="container3">
<!-- Begin #content -->
<div id="content">
<?php mospathway() ?>
<?php mosMainBody(); ?>
</div><!-- //content -->
<!-- #left sidebar -->
<div id="sidebarLT">
left side bar:<br />
<?php mosLoadModules('left', -2);?>
<?php mosLoadModules('right', -2);?>
</div><!--//sidebarLT -->
</div><!--//container3-->
<!-- #right sidebar -->
<div id="sidebarRT">
<?php mosLoadModules('top', -2);?>
<?php mosLoadModules('user1', -2);?>
<?php mosLoadModules('user2', -2);?>
</div><!--//sidebarRT -->
</div><!--//container2-->
<!--<a name="mainNav"> </a>-->
<div id="tabbar"> </div>
<div id="top_navlist">
<?php mosLoadModules ( 'user3', -2 ); ?>
</div>
<!--//top_navlist-->
<div id="footer">
<?php include_once($mosConfig_absolute_path .'/includes/footer.
php'),?>
</div><!--//footer-->
</div><!--//container-->
</body>

When we save the index.php file, press Alt+tab, and click on Refresh, we get something similar to the following:

Adding Joomla! Modules and Content

Figure 3.28 Seeing the layout with content

Module Options

You will notice that, in each bit of PHP code, in addition to the standard mosLoadModule() syntax that we discussed earlier, we’ve added a, -2 after the module name. This has been done so that we can take advantage of the $style option in the mosLoadModule() functions.

You can set the $style option to be 0, 1, -1, -2, or -3. These settings provide you with the following options:

  • 0: Modules are displayed in a table with a single row and column. This is the default setting, and you will never really need to use it.

  • 1: Modules are displayed in a table with a multiple column rows, giving it the effect of being displayed horizontally, rather than vertically like the default.

  • -1: Modules are displayed in plain-text output, without titles.

  • -2: Modules are displayed wrapped in a single <div> tag, with titles in <h3> header tags.

  • -3: Modules are displayed wrapped in several <div> tags with titles in <h3> header tags allowing for more complex CSS styling to be applied, such as stretchable, rounded corners.

We’ve chosen -2 for our modules so that we can control their layout more easily with CSS and also reduce the number of tables in our template from over 19 to 8.

There is another way to control your menu module output. We want our menus to be displayed as bulleted lists or “flat lists” so that we can control them using more powerful CSS techniques.

Go to Modules | Site Modules and select Main Menu. You will then notice that in the Joomla! Administration Panel, you can select the menu’s style. You can do this for all menus created with the Module Manager by selecting Flat List from the Menu Style option as shown in Figure 3.29:

Module Options

Figure 3.29 Setting the main menu module to flat list

Our Top Menu, Latest News, and Popular link menus are already using this Flat List option.

You’ve probably also noticed that, in restructuring the content semantically, the module names no longer match with the main div content holder areas. For instance, we have mosLoadModules code for both the left and right modules inside the left side div.

If you know that you’re the only person who is going to be editing the template, this is probably fine. However, if you want to keep it clear and simple for your client or another Joomla! developer who might have to take over your template, then you will want to fix it. This can be done by going to your Joomla! Administration Panel, selecting Modules | Site Modules, and then repositioning the modules into more appropriately named position slots. You can also select Site | Template Manager | Module Positions and create your own custom module position names. You will then have to go back into the Site Modules manager and assign the elements to their new Module Position. Also, if you do change the names in the Joomla! Administration Panel, don’t forget to update your template index.php file with the new module name inside the mosLoadModules code.

Be aware that, if you create your own position names, you will need to inform your client or Joomla! administrator that they need to create these module positions in the Module Position Manager in order for your template package to install properly and work.

Styling the New Template

We’re now at a point very similar to where we started at the beginning of this chapter. We have a template which has its general layout in place. With a few key color changes, creative font application, and background images, we will pretty much have our well styled, new, and improved template.

Our CSS file already has our own core id rules for our template layout. We will start with assigning colors and general properties. After that, moving forward will be exactly like the Rhuk template (at the beginning of this chapter), we will select text and use Firefox’s DOM inspector to show us what class and id rules the Joomla! content is spitting out so that we can create customized CSS rules for each element, bringing in our background images and final touches.

Note

Awesome CSS List Techniques Listamatic and Listamatic2 from Max Design (http://css.maxdesign.com.au/index.htm) are wonderful resources for referencing and learning different techniques to creatively turn list items into robust navigation devices. It’s what we’ve used to create our Top, Main, and Content Menus in our new semantic template. Our Top Menu uses the Rollover horizontal list nav bar: http://css.maxdesign.com.au/listamatic/horizontal03.htm and our Main Menu uses the Rollover lists: http://css.maxdesign.com.au/listamatic/vertical08.htm.

We just added our background images to these techniques and our navigation came right together.

Our header area has changed in size, so we will need to go back into our image editor and reexport a header image that’s wider so that it accommodates our new semantic template better.

When all is said and done, and our fonts and images are placed into our template_css.css sheet, we should have a template that looks like the following:

Styling the New Template

Figure 3.30 Final Semantic Template View

To compare your template to mine, please refer to the Table-less Design section in Appendix A, where you can view the complete template_css.css style sheet and the index.php template code in its entirety.

If you felt accomplished earlier, then having reworked the rhuk_solarflare_ii template, you should be ecstatic at this point for accomplishing your first semantic, table-less, CSS Joomla! template. Great job!

Summary

You’ve now learned how to set up your development environment (a.k.a. sandbox) and an HTML editor for a smooth workflow. We also showed you some alternatives to a full Joomla! install. You now have two versions of your design—one with tables that was leveraged from the rhuk_solarflare_ii template and one from scratch, with semantic XHTML and CSS. Believe it or not, we’re not quite done!

In the next chapter, we will continue working with our layouts, showing you some tips and tricks for debugging IE quirks as well as running it through a thorough validation process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset