Archive for the ‘Templates’ Category

A min-max that works in almost ALL modern browsers (even IE!)

Thursday, June 15th, 2006 by Jonathan

Not being able to use min-max in CSS layouts is a thorn in virtually every designer’s side. I have been testing different theories and complex codes for over 6 months now trying to get something that is both easy to use and is consistent across all modern browsers. About 3 months ago I ran across some information on IE’s conditional statements that made me think about the possibility of roping in IE to use them. After finally getting a min-width to work I knew a true min-max would be possible. After a few more weeks of testing, it finally worked and my world was never the same again!

In this example I will create a flexible layout window with a min-width of 700 and a max of 1100 that centers in the window.

Step 1

Lets start with the XHTML you will need for this example:


<body>
<div id="wrap-page">
<div id="content">
<p>Here is a page that has a min-max set from 700px to 1100px and it works in all modern browsers, including IE.</p>
</div>
</div>
</body>

Pretty simple! Now let’s get to the heart of the layout – the CSS.

body {text-align: center;}
#wrap-page {
min-width:700px;
max-width:1100px;
height: 100%;
text-align: left;
margin: 5px auto;
}
#content {
background-color: #FFFF99;
border: thin dotted #000000;
}


Well, that takes care of all the good browsers. Now let’s take care of IE. The following code goes into the head of the page, but I recommend moving it into an external style sheet just for IE (just make an @import between the [if IE] style statements).


<!--[if IE]>
<style type="text/css">
#wrap-page {width: 700px;}
div#wrap-page { width:expression(((document.compatMode &&
document.compatMode=='CSS1Compat') ?
document.documentElement.clientWidth : document.body.clientWidth)
> 1118 ? "1100px" : (((document.compatMode &&
document.compatMode=='CSS1Compat') ?
document.documentElement.clientWidth :
document.body.clientWidth) < 718 ? "700px" : "99.7%")); }
</style>
< ![endif]-->

I won’t bore you with details, but this basically looks at the width of the client’s window and carries out the statements. If it goes below 700 then set the width fixed at 700. It will stretch until it hits 1100 then fix the width at 1100. I did a ton of testing on this to come up with these numbers. Basically, keep the first number around 18 pixels wider than your intended width, otherwise you won’t get a smooth transition when it hits the min-max point. Also, make sure you don’t set the last variable to 100% or the screen will occasionally stick in it’s max position.

This has been tested on every browser I have on both a mac and pc. The only browser that doesn’t support it is macIE5x. This includes Netscape6-8, IE5-6, Camino, Safari, OmniWeb, Opera 6-8, iCab, etc.

How to make Joomla! templates without tables

Wednesday, June 14th, 2006 by Jonathan

Did you know you can dynamically wrap modules in div tags within your Joomla! templates to make it tableless? For some this is old news, but for new users this could be a dream come true (I know it was for me when I first found out about it). With this knowledge, you can make your template validate XHTML and CSS, and almost WAI 1.0 Priority 1 in a default install of Joomla!

Step 1

I guess the obvious should be said first. Make your Joomla! template without any tables. After you find one that fits your style, insert the modules into your template where you want your text to go.

Step 2

You may have noticed that there are numbers after some of the module names in some example templates (example: < ?php mosLoadModule ( ‘left’, -3 ); ?>). This is where the magic happens! Just follow the list below to figure out what fits your needs the best:

  • < ?php mosLoadModule ( ‘left’, -1 ); ?>
    No code goes around the module and no title.
  • < ?php mosLoadModule ( ‘left’, -2 ); ?>
    Wraps the entire module in a div class=”module”‚ with the module’s title in an h3.

  • <div class="module">
    <h3>Title</h3>Module Info
    </div>

  • < ?php mosLoadModule ( ‘left’, -3 ); ?>
    Creates 3 extra divs along with the h3 title tag to give you flexibility with the module container. We will be adding a section just for code to add to your style sheets to get special borders and other effects with this style sometime soon.

  • <div class="module">
    <div>
    <div>
    <div>
    <h3>Title</h3>Module Info
    </div>
    </div>
    </div>
    </div>

  • < ?php mosLoadModule ( ‘left’, -4 ); ?>
    Wraps the module in a table (not what we want here, but now you know how to do it).

  • <table cellpadding="0" cellspacing="0" class="moduletable">
    <tr>
    <th valign="top">
    Module Title
    </th>
    </tr>
    <tr>
    <td>
    Module info
    </td>
    </tr>
    </table>

Step 3

The last part is to make your menus display as Flat lists.

Go to your module area and select main menu (or whatever you named your main menu). Under Parameters go to the fourth selection down where it says Menu Style. Change it to Flat List. This will make your menu an unordered list instead of a table (which is what the other selections do).


<ul id="mainlevel">
<li>
<a href="/page1" class="mainlevel" id="active_menu">Page 1</a>
</li>
<li>
<a href="/page2" class="mainlevel" >Page 2</a>
</li>
</ul>

Since the menu module that comes with Joomla! doesn’t display child menu items, you may want to use a third party menu module. I recommend using Extended Menu (http://de.siteof.de/extended-menu.html) if you are in need of more options. This will give you so many options that your head will spin! It can do anything you can imagine with unordered list menus. There are also some good menu systems you can download for free, such as Suckerfish Menus and tree menus. They plug directly into Extended Menu’s administration area for ease of use.

We hope this has helped shed some light on the world of Tableless Joomla! Templates. We will be adding much more information to help ease your transition into this new and exiting world of accessible web design. Joomla! truly is the best CMS available for accessible web sites that I’ve ever seen and we hope more people will jump on board.