Difference between revisions of "Template Code Comparison of J1.5 and J3.x"
From Joomla! Documentation
Conlippert (talk | contribs) (Corrected rows for Retreiving Joomla Framework and Retrieving Base URL) |
Betweenbrain (talk | contribs) (Removed PHP tags) |
||
Line 25: | Line 25: | ||
|- | |- | ||
| Retreive the Sitename | | Retreive the Sitename | ||
− | | <pre> | + | | <pre>$mainframe-> getCfg('sitename');</pre> |
− | | <pre> | + | | <pre>$app->getCfg('sitename');</pre> |
|- | |- | ||
| Retrieve Error Codes | | Retrieve Error Codes | ||
Line 41: | Line 41: | ||
|- | |- | ||
| Active Language | | Active Language | ||
− | |<pre> | + | |<pre>$this->language;</pre> |
− | |<pre> | + | |<pre>$doc->language;</pre> |
|- | |- | ||
| View | | View | ||
Line 61: | Line 61: | ||
|- | |- | ||
| Homepage detection | | Homepage detection | ||
− | |<pre>JRequest::getVar( 'view' ) == 'frontpage'</pre> | + | |<pre><?php if(JRequest::getVar( 'view' ) == 'frontpage') ?></pre> |
− | |<pre><?php $menu = $app->getMenu(); | + | |<pre><?php $menu = $app->getMenu(); |
− | + | if($menu->getActive() == $menu-> getDefault()) ?></pre> | |
|- | |- | ||
| Main Content | | Main Content |
Revision as of 08:53, 31 October 2014
The table below is a quick reference of code differences between a Joomla 1.5 and Joomla 3.x template's index.php
file.
Description | In a 1.5 Template(index.php) you might see | Recommended J3.x Template(index.php) code |
---|---|---|
First Line | <?php defined( '_JEXEC' ) or die( 'Restricted access' );?>
|
No change |
DOCTYPE | <!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="en" lang="en" dir="ltr"> |
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"> |
Access to Joomla Framework | $app = JFactory::getApplication(); |
No change |
Retreive HTML headers from Joomla | <jdoc:include type="head" /> |
No change |
Retreive the Sitename | $mainframe-> getCfg('sitename'); |
$app->getCfg('sitename'); |
Retrieve Error Codes | $this->error->code |
$this->error->getCode(); |
Retrieve Error Messages | $this->error->message |
$this->error->getMessage(); |
Retrieve System Messages | $this->getBuffer('message') |
<jdoc:include type="message" /> |
Active Language | $this->language; |
$doc->language; |
View | JRequest::getVar( 'view' ) |
$app->input->getCmd('view', ''); |
Task | JRequest::getVar( 'task' ) |
$app->input->getCmd('task', ''); |
Layout | JRequest::getVar( 'layout' ) |
$app->input->getCmd('layout, ''); |
ID | JRequest::getVar( 'id' ) |
$app->input->getCmd('layout, ''); |
Homepage detection | <?php if(JRequest::getVar( 'view' ) == 'frontpage') ?> |
<?php $menu = $app->getMenu(); if($menu->getActive() == $menu-> getDefault()) ?> |
Main Content | <jdoc:include type="component" /> |
No change |
Modules & Positions | <jdoc:include type="modules" name="right" style="xhtml" /> |
No change |
Retrieve Base URL | $url = clone(JURI::getInstance()); echo $this->baseurl; JURI::root()*; |
JURI::base(); $this->baseurl; |