Plantillas: Comparación de Código entre J1.5 y J3.x

From Joomla! Documentation

This page is a translated version of the page Template Code Comparison of J1.5 and J3.x and the translation is 100% complete.
Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français

La siguiente tabla es una referencia rápida de las diferencias de código del archivo index.php de una plantilla entre Joomla! 1.5 y Joomla! 3.x.

Descripción En una Plantilla (index.php) 1.5 se puede ver Código recomendado de la Plantilla J3.x (index.php)
Primera Línea <?php defined( '_JEXEC' ) or die( 'Restricted access' );?> Sin cambios
DOCTYPE
<?php echo '<?xml version="1.0" encoding="utf-8"?'.'>'; ?><!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; ?>" dir="<?php echo $this->direction; ?>" >
<!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; ?>">
Acceder al Framework de Joomla!
$app = JFactory::getApplication(); OR 
require_once (‘includes/../framework.php' );
$mainframe =& JFactory::getApplication('site');
Sin cambios, pero debe tener este aspecto:
$app = JFactory::getApplication();
Recuperar las cabeceras HTML desde Joomla!
<jdoc:include type="head" />
Sin cambios
Recuperar el Nombre del Sitio
$mainframe->getCfg('sitename');
$app->get('sitename');
Recuperar Códigos de Error
$this->error->code
$this->error->getCode();
Recuperar Mensajes de Error
$this->error->message
$this->error->getMessage();
Recuperar Mensajes del Sistema
$this->getBuffer('message')
<jdoc:include type="message" />
Idioma Activo
$this->language;
$doc->language;
Vista
JRequest::getVar( 'view' )
$app->input->getCmd('view');
Tarea
JRequest::getVar( 'task' )
$app->input->getCmd('task');
Diseño
JRequest::getVar( 'layout' )
$app->input->getString('layout', 'default');
ID
JRequest::getVar( 'id' )
Con alias:
$app->input->getString('id');
Sólo ID:
$app->input->getInt('id');
Detección de la página principal
<?php if(JRequest::getVar( 'view' ) == 'frontpage') ?>
<?php $menu = $app->getMenu();
if($menu->getActive() == $menu->getDefault()) ?>
Contenido Principal
<jdoc:include type="component" />
Sin cambios
Módulos y Posiciones
<jdoc:include type="modules" name="right" style="xhtml" />
Sin cambios
Recuperar la dirección URL Base
$url = clone(JURI::getInstance());
echo $this->baseurl; 
JURI::root()*; 
JURI::base();
$this->baseurl;
Acceder a las Clases Documentos de Página
$doc = JFactory::getDocument();
Sin cambios

Sin embargo, el uso de "$this->" es equivalente.

Acceder a los Parámetros de la Plantilla
echo $this->params->get('colorVariation');
Sin cambios