[4.5] Mambo 4.5 to 4.5.1 template conversion
Written by Arthur Konze   
Thursday, 30 September 2004

An article by Mamboportal.comWith Mambo 4.5.1 the template engine has changed again. The developers aim is to prepare the system for the upcoming changes in Mambo 4.5.2 and Mambo 4.6. At the moment all 4.5 templates do run inside Mambo 4.5.1 without any problems. But it is recommended to change your templates to the new functions to stay upwards compatible.

To make this as easy as possible for every designer, Mamboportal.com has written a small tutorial for you. We show you detailed, which changes have to be made to get your template ready for 451.

The new header
Mambo 4.5.1 now supports the HTML title tag. It shows the actual website title and the title of the current content item the user is viewing. To use this feature in your templates you have to change the header of your template. If you do not use any custom enhancements in the header, the following example header should serve you well:

<?php
/**
* YourTemplatesName - A Mambo 4.5.1 template
* @version 1.0
* @package YourTemplatesName
* @copyright (C) 2004 by Your Name
* @license Your license name here
*/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$iso = split( '=', _ISO );
echo '<?xml version="1.0" encoding="'. $iso[1] .'"?' .'>';
?>
<!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>
    <?php if ( $my->id ) initEditor(); ?>
    <meta http-equiv="Content-Type" content="text/html; <?php echo _ISO; ?>" />
    <?php mosShowHead(); ?>
    <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['mosConfig_live_site']; ?>/templates/yourtemplatesname/css/template_css.css" />
  </head>

Note: Make sure you replace all names with the name of your template. The most important is the replacement of the name in the path to the CSS file.

 

The Pathway loader
In Mambo 4.5 a php include command was used to load the "pathway.php" file. The new version 451 introduces the "mosPathWay" function, which takes over the job. This leads us to the following replacement:

Old wayNew way
<?php include_once("pathway.php"); ?><?php mosPathWay(); ?>

 

Loading the Mainbody
The old way of loading the mainbody.php with an include command has been exchanged with a new core function. This function is called "mosMainBody". So you have to replace th following:

Old wayNew way
<?php include_once("mainbody.php"); ?><?php mosMainBody(); ?>

 

Global variables
Mambo 4.5.1 introduces a new variable system, which will lead to a much better handling of global settings in upcoming versions of Mambo. To make your templates safe for the future, just replace the following variables:

Old wayNew way
$mosConfig_live_site$GLOBALS['mosConfig_live_site']
$mosConfig_absolute_path$GLOBALS['mosConfig_absolute_path']
$mosConfig_sitename$GLOBALS['mosConfig_sitename']
$mosConfig_offset$GLOBALS['mosConfig_offset']

 

Showing banners
Banners are now displayed using a banner module and not using a direct access to the component itself anymore. Therefore you have to add a special module position called "banner" at the place where you want to display your ads. Replace the following:

Old wayNew way
<?php mosLoadComponent( "banners" ); ?><?php mosLoadModules( 'banner', -1 ); ?>

 

The Pathway arrow
Since Mambo 4.5.1 you have the chance to change the orange arrow image, which is used as a divider between the different pathway level. To do so, just create an image called "arrow.png" and place it inside the /images folder of your template. Make sure you also add the new image to the XML installer file, otherwise it will not be installed with the template.