September 2009

HTML style guide

Submitted by bas on Wed, 16/09/2009 - 14:49

When designing websites graphic designers often draw a neat picture in photoshop. The day to day use of a website greatly differs from this ideal scenario. The design shows a calm and readable site with demo text. But the actual website in use everything but serene and readable. The text style is usually the first aspect of a site that gets diluted. Both users and visitors create content or leave comments which just don't fit the initial picture painted by the designer. A lot of problems stem from the use of wysiwyg editors in content management systems.

JRoute and module visibility

Submitted by bas on Sat, 12/09/2009 - 20:04

Correct SEF routing in Joomla is pretty easy thanks to the class JRoute. If you want to redirect to a clean url just use the basic method _(); like so:


Unfortunately, this method isn't aware of url aliases created in menu items. JRoute just alters a dirty url like /index.php?option=com_example&task=view in a clean url like /components/example/view. Let's say you've created menu item to this components task with the alias: /view-example. JRoute doesn't redirect to the alias, just to the cleaned up system url. This is a problem because menu items are essential if you want to define page parameters or module visibility. These parameters are only visible if the url matches exactly. If you want to create redirects to url aliases in your Joomla modules or components you can try the following snippet.

$menu =& JSite::getMenu();
$menu_items = $menu->_items;
foreach($menu_items as $item) {
    $match = 0;
    if($item->query['option'] == 'com_example')    $match = $match+1;
    if($item->query['task'] == 'view') $match = $match+1;
    $matches[$match] = $item->route;
if(key_exists(1, $matches)) {
    array_reverse($matches, false);
    $action_url = JRoute::_(JUri::base(true).'/'.$matches[0]);

This will create a path to a single alias created in a menu item if a matching menu item exists. You can also do this for other components by specifying the match criteria. For example: