Saturday, August 15, 2009

Joomla Accessibility and other stuff

The Beez template practices a good approach to accessibility for us all to follow, but I do have some concerns.

Using ems in CSS


It has been the tradition to specify all fonts sizes as ems which allows everything to size in relation to it's context. This has always appeared to me to be a best practise, but it is also difficult to do if you allow the fonts to be zoomed. Allowing users to zoom is pretty important for users whether they have a visual disability or not.

Body text and Headings are fine to scale as this should flow easily but there can be issues with navigation falling apart if the font is zoomed by the user so it get's quite tricky.

Catching up on Boagworld podcasts I heard in interesting discussion where several leading lights in web design and CSS are starting to hard code font-sizes in pixels which seems like a backward step, however there are some pretty good arguments. The main argument is that most common browsers now support Pixel Zooming instead of font zooming, which means that the layout of the design remains as the page is zoomed so this is a good thing for people trying to maintain the integrity of their design/layout but still enabling users to zoom. There has apparently been some heated debate. You can catch the discussion at http://boagworld.com/podcast/171.

For me there are some interesting points and I am tempted to combine the two approaches i.e. use relative em based sizes for content and fixed pixel fonts for things like navigation.

What this does also emphasise is the need or lack of need for JavaScript based font sizing as found in templates such as beez. The browser has all the controls already and users who need to increase font size for readability will most likely know where these are as they will need to use those features for sites which don't have zoom features.

Liquid layouts


For me, liquid layouts are cool but I am not sure what use they are. They are certainly an excellent demonstration of best practise CSS and markup, but in reality I am not sure they are that useful. I won't be using liquid layouts for my design, but that doesn't mean they shouldn't be used.

Semantic Markup


This topic however is critical for accessibility. Making a site accessible (for sight impared users) is technically quite easy, making the site make sense for them is much harder. I have seen that semantic markup is a benefit in SEO, presenting a much more understandable page for the search engines to index. So it is common sense to make the effort to markup content semantically.

The important thing to do is tag the content with the appropriate tags so the content is structurally marked up. The common tags would be Headings, Lists, paragraphs, Strong, Blockquote, Emphasise etc. whereas "bad tags" would be bold, italic, font etc. I found this article http://blue-anvil.com/archives/guide-to-semantic-mark-up which is quite a good explanation and goes on to provide some of the benefits including the SEO advantages. There is also a great guideline on the BBC's website from their future media and technology department.

Using semantic markup ensures machines and users can always tell the structure of a document and see where the emphasis is important, there is a huge benefit in Search Engine Optimisation so this for me is a no-brainer.
Rich Text Editors and Semantic Markup
Users love to be able to format their content just how they want it, which can end up with some interesting design issues where fonts are applied, sizes are hardcoded etc.. This can lead to some really horrible page designs and all the hard work on the template kinda wasted. It is also pretty nasty if you want to re-skin your site when users have hard coded style changes etc.. My plan will be to disable all those items in JCE and just leave tag markup options. We will see how this goes as to whether it is accepted by the editors.

Template Layout and making it more readable for screen readers and Search engines


The other angle which I am not sure whether this is part of Semantic mark-up or not but is very closely related is how the rest of the web page is constructed. If you go to any web page and turn off images, javascript and CSS to emulate what search engines and screen readers see, this will be a great demonstration of just how much sense your web page makes to a screen reader user or a search engine. Just as you want your core content to be in the right place in your visual design, so should your core content be in the right place when read by a machine. As an example left columns further down the page may not visually be the dominant content on the page, therefore the less important content is usually placed there. If you look at the page source or disable CSS and images you often find that that content is higher in the page than the more important content.

Take for example this page in the Joomla docs http://docs.joomla.org/How_do_you_get_rid_of_the_breadcrumbs%3F. If you turn off CSS while viewing the page, you will see that it still makes sense, the content is displayed first and some simple links at the top which allows someone to skip to the navigation, which is particularly useful for screen reader users.

A quick look at my own template from the last post shows me I have some serious work to do. The first items seen are a login form, a search form, navigation, and then some content. No where on the page does it tell me what web site this is or even what page I am on! So I have alot of work to do on that, which will get covered in another post.

Wednesday, August 5, 2009

Building a template - Home page, JRequest, and basic layout

For me it's key to having a home page that drives the right behaviour, presents all kinds of content to users for them to read and makes the home page not look like a Joomla home page.


I have had a look around http://extensions.jooml.org and can't find anything that helps with this kind of layout so I am going to keep it simple and use a lot of the contentItem module to achieve this. On the home page I will have three positions which will contain contentItme modules with specific uncategorised articles and then below that 3 columns with various modules including the contentItem module to list articles from varying different locations.

There is nothing very special in my template layout apart from trying to keep the number of divs to a minimum.

Introducing JRequest

One thing I did discover which I think will be very useful down the line is
JRequest::getVar('view')
This will return what type of view you have e.g. blog list, front page, section, category etc. I first discovered this on this site http://www.howtojoomla.net/2008041785/how-tos/templates/how-to-determine-which-page-you-are-on-from-within-a-joomla-15-template on which someone had added the code for the view option in the comments at the bottom of the page. Some judicious searching didn't bring up any decent docs in the joomla sites but I did find this http://www.theartofjoomla.com/home/7-legacy/8-removing-a-legacy-part-2.html which gives some idea of the different calls that can be made.

Having this information is going to be pretty handy for all kinds of decisions in the template, but I think that it would be useful having some generic classes on "view" and "option" in CSS at a body tag level. I have set two variables and then used these in my body tag's class declarations.

<?php
$viewName = JRequest::getVar('view');
$optionName = JRequest::getVar('option');
?>
<body id="page_bg" class="<?php echo $viewName. ' ' .$optionName;?>">

Template layout

Now that I have some variables which I can use to test for the front page it is pretty simple to exclude items such as breadcrumbs and secondary navigation by testing $viewName like this

<?php if ($viewName=='frontpage') :?>
//markup for top panels on home page
<?php else :?>
<div id="secondary-nav"><jdoc:include type="modules" name="secondarymenu" style="xhtml"/> </div>
<div id="pathway"><jdoc:include type="modules" name="breadcrumb" style="xhtml"/> </div>
<?php endif; ?>
Then to achieve 3 columns of content below the header area on the home page and only two colums on any other page I therefore done the following

<?php if ($viewName=='frontpage') : ?>
<div id="leftcolumn"><jdoc:include type="modules" name="left" style="xhtml" /> </div>
<div id="maincolumn">
<div id="centre"><jdoc:include type="modules" name="centre" style="xhtml"/> </div>
<div id="rightcolumn"><jdoc:include type="modules" name="right" style="xhtml"/> </div>
<?php else: ?>
<div id="maincolumn">
<div id="content"><jdoc:include type="component" /> <jdoc:include type="modules" name="footer" style="xhtml"/> </div>
<?php if($this->countModules('right') and JRequest::getCmd('layout') != 'form') : ?>
<div id="rightcolumn"><jdoc:include type="modules" name="right" style="xhtml"/> </div>
<?php endif; ?>
<?php endif;?>

That's almost it for my template, I am sure that there will be more tweaks as time goes on, now for the hard bit which is getting the CSS right. If anyone is interested here is the whole template (it's a work in progress).
<?php
/**
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
// useful variables
$viewName = JRequest::getVar('view');
$optionName = JRequest::getVar('option');

?>
<!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="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/devtemplate/css/template.css" type="text/css" />
<!--[if lte IE 6]>
<link href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/ieonly.css"rel="stylesheet"type="text/css"/>
<![endif]-->
<?php if($this->direction == 'rtl') : ?>
<link href="<?php echo $this->baseurl ?>/templates/devtemplate/css/template_rtl.css" rel="stylesheet" type="text/css" />
<?php endif; ?>
<script type="text/javascript" src="http://serve.a-widget.com/kickFlash/scripts/swfobject2.js"></script>
</head>

<body id="page_bg" class="<?php echo $viewName. ' ' .$optionName;?>">
<a name="up" id="up"></a>
<div id="wrapper">
<div id="top">
<div id="login"> <jdoc:include type="modules" name="login" style="xhtml"/></div>
<div id="search"> <jdoc:include type="modules" name="search" style="xhtml"/> </div>
<div class="clear"></div>
</div>
<div id="header">
<div id="logo"></div>
<div id="primary-nav"> <jdoc:include type="modules" name="mainmenu" style="xhtml"/> </div>
<div class="clr"></div>
<?php if ($viewName=='frontpage') :?>
<div id="home-core-panels">
<div id="home-top-left"><jdoc:include type="modules" name="home-top-left" style="xhtml" /> </div>
<div id="home-top-main">
<div id="home-top-centre"><jdoc:include type="modules" name="home-top-centre" style="xhtml" /></div>
<div id="home-top-right"><jdoc:include type="modules" name="home-top-right" style="xhtml" /></div>
</div>
<div class="clr"></div>
</div>
<?php else :?>
<div id="secondary-nav"><jdoc:include type="modules" name="secondarymenu" style="xhtml"/> </div>
<div id="pathway"><jdoc:include type="modules" name="breadcrumb" style="xhtml"/> </div>
<?php endif; ?>
</div>
<div id="maincontent">
<jdoc:include type="message" />
<?php if ($viewName=='frontpage') : ?>
<div id="leftcolumn"><jdoc:include type="modules" name="left" style="xhtml" /> </div>
<div id="maincolumn">
<div id="centre"><jdoc:include type="modules" name="centre" style="xhtml"/> </div>
<div id="rightcolumn"><jdoc:include type="modules" name="right" style="xhtml"/> </div>
<?php else: ?>
<div id="maincolumn">
<div id="content"><jdoc:include type="component" /> <jdoc:include type="modules" name="footer" style="xhtml"/> </div>
<?php if($this->countModules('right') and JRequest::getCmd('layout') != 'form') : ?>
<div id="rightcolumn"><jdoc:include type="modules" name="right" style="xhtml"/> </div>
<?php endif; ?>
<?php endif;?>
<div class="clr"></div>
</div>
<div class="clr"></div>
<div id="footerspacer"></div>
</div>
<div id="footer">
<p id="syndicate"> <jdoc:include type="modules" name="syndicate" style="xhtml"/> </p>
<p id="power_by"> <?php echo JText::_('Powered by') ?> <a href="http://www.joomla.org">Joomla!</a>. <?php echo JText::_('Valid') ?> <a href="http://validator.w3.org/check/referer">XHTML</a> <?php echo JText::_('and') ?> <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>. </p>
</div>
</div>
<jdoc:include type="modules" name="debug" />
</body>
</html>