Joomla 1.5 Templates
Upgrading your index.php file
For templates built for Joomla 1.0.x, you must change a few things for them to work under Joomla 1.5. This is a non-exhaustive list of things to change:
- Replace $mosConfig_absolute_path with JURI::base(). For example:
//include_once($mosConfig_absolute_path . '/mylib.php'); include_once(JURI::base() . '/mylib.php');
- Replace $mosConfig_live_site with $mainframe→getCfg( 'live_site' ) or JURI::base(). For example:
<a href="<?php /*echo $mosConfig_live_site;*/ ?>">My Site</a> <a href="<?php echo $mainframe->getCfg( 'live_site' ); ?>">My Site</a>
- Replace fixed strings with translatable strings. For example:
//echo 'Welcome'; echo JText::_( 'Welcome' );
- Replace calls to mosGetParam() with calls to JRequest::getVar(). For example:
//$id = mosGetParam( $_REQUEST, 'id', 0 ); $id = JRequest::getVar( 'id', 0 );
- Replace mosShowHead(); with <jdoc:include type=“head” />. For example:
<?php /* mosShowHead();*/ ?> <jdoc:include type="head" />
- Replace mosMainBody() with <jdoc:include type=“component” />
<?php /*mosMainBody();*/ ?> <?php /*include ("mainbody.php");*/ ?> <jdoc:include type="component" />
- Replace mosLoadModules( $position_name, $style ); with <jdoc:include type=“modules” name=$position_name style=$style />. For example:
<?php /*mosLoadModules ( 'left' );*/ ?> <?php /*mosLoadModules ( 'right' );*/ ?> <jdoc:include type="modules" name="left" /> <jdoc:include type="modules" name="right" /> //or <jdoc:include type="modules" name="left" style="mycssstyle" headerLevel="3" /> <jdoc:include type="modules" name="right" style="mycssstyle" headerLevel="3" />
- Declare variable $cur_template before you start using it. For example:
$cur_template = JRequest::getVar( 'template', $mainframe->getTemplate(), 'default', 'string' );
Syntax for Reengineered Objects and Methods
Object/Method | Joomla 1.0.x | Joomla 1.5 | Note |
---|---|---|---|
Access restriction | <?php defined( '_VALID_MOS' ) or die( 'Restricted access.' ); ?> | <?php defined( '_JEXEC' ) or die( 'Restricted access' ); ?> | |
Header | <?php mosShowHead(); ?>; | <jdoc:include type=“head” /> | |
Main body | <?php mosMainBody(); ?> or <?php include (“mainbody.php”); ?> | <jdoc:include type=“component” /> | |
Module | <?php mosLoadModules ( 'left' ); ?> | <jdoc:include type=“modules” name=“left” /> or <jdoc:include type=“modules” name=“left” style=“mycssstyle” headerLevel=“3” /> | |
Site name | <?php echo $mosConfig_sitename; ?> | <?php echo $mainframe→getCfg('sitename');?> | This new method works for all configuration.php parameters |
Base URL | <?php echo $mosConfig_live_site; ?> | <?php echo JURI::base(); ?> or <?php echo $mainframe→getCfg( 'live_site' ); ?> | |
Base path | <?php echo $mosConfig_absolute_path; ?> | <?php echo JPATH_SITE; ?> | |
Base path | <?php echo $mosConfig_absolute_path.'/administrator'; ?> | <?php echo JPATH_ADMINISTRATOR; ?> | |
Base path | <?php echo $mosConfig_absolute_path.'/installation'; ?> | <?php echo JPATH_INSTALLATION; ?> | |
Root path | <?php echo $mosConfig_absolute_path; ?> | <?php echo JPATH_ROOT; ?> | Base path, irrespective of site, administrator, or installation. |
Link to Home | <a href='<?php echo “index.php?option=com_frontpage&Itemid=1”; ?>'>Home</a> | <a href=“<?php echo JURI::base(); ?>index.php?option=com_content&view=frontpage”>Home</a> |