Home arrow Joomla! arrow Templatedesign arrow Templates 1.0 -> 1.5

Firefox Ad

Herzlichen Glückwunsch zu Ihrem Browser..
Durch die Weiten des WEBs mit:

An apple a day keeps the doctor away...


Joomla-Shop


NiK-IT.de Barcode


Templates 1.0 -> 1.5 PDF Drucken E-Mail
Mittwoch, 18. Oktober 2006
Templates von Joomla! 1.0 an Joomla! 1.5 anzupassen ist gar nicht so schwer...
... oder doch ? diese Doku muss noch einmal überarbeitet werden... siehe:
forum.joomla.org

UPDATE:

---------------------------------------------------

Oke guys as promised I have reviewed my orginal implementation and made an extensive amount of changes to the site template handling. What has been changed : 1. patTemplate is no longer used to render the site templates. This creates a nice speed increase of about 0.050 msec on my machine on a page load of +/- 0.4 sec. This means a 1/8 speed improvement. 2. and have been replaced by countModules function This change creates alot more flexibility. The countModules function can be giving a condition made up out of module positions. For example : - countModules('user1 and user2'), will return 1 if there are module(s) in user1 and user2 position - countModules('user1 or user2'), will return1 if there are module(s) in user1 or user2 position - countModules('user1 + user2'), will return the total amount of modules in user1 and user2 position I believe this function will cover all your needs to create flexible templates that adpat themselves to published modules. 3. The template paremeters can be accessed using a bit of simple php code.
<? if($this->params->get('showComponent')) : ?>
     <jdoc:include type="component" />
<? endif; ?>
4. Variables accessible through the template $this->language, the language tag $this->direction, the language direction $this->template, the template name $option, $mainframe, $Itemid are also accessible if needed. 5. How does the system render a site template ? Site templates are rendered in two stages, - first all PHP functions are executed and all variables are replaced by their values - secondly the system searches for all the jdoc::include statements and replaces them with the output of the modules, component,... I think these changes bring back the needed flexibility and as a bonus we get a decent speed increase. Power to the designers Wink Have a look at the changes made and let me know your thoughts. In the coming weeks I will be doing a series of blog posts to outline all the changes in the template system. Johan

---------------------------------------------------

To use the original example (creating a two/three column layout) :
<? if($this->countModules('right') : ?>
<div id="extras"><jdoc:include type="modules" name="right" style="rounded" /></div>
<div id="content">
       <jdoc:include type="component" />
 
       <jdoc:include type="modules" name="breadcrumb" style="rounded" />
</div>
<? else : ?>
<div id="contentwide">
      <jdoc:include type="component" />
 
       <jdoc:include type="modules" name="breadcrumb" style="rounded" />
</div>
<? endif; ?>

*Note : the style attributes are using the proper correct namings, the numeric style names are only supported with legacy activated.

  • -3 = rounded
  • -2 = xhtml
  • -1 = raw (default)
  • 0 = table

When no style is giving the system assumes a -1.

This should get u started, countModules can do alot more but i'll leave that for another time.
« Last Edit: October 23, 2006, 07:57:00 PM by Jinx »

---------------------------------------------------

Die Installer xml Datei

Die Änderungen an der Installer.xml Datei sind trivial. Da jetzt "flächendeckend" das mos eliminiert ist, heisst es jetzt konsequenterweise statt mosinstall nur noch install..

J! 1.0
<mosinstall type="template">
...
</mosinstall>
J! 1.5
<install type="template">
...
</install>

Danach sollte es sich installieren lassen.

Die index.php

Hier sind etwas mehr Änderungen nötig. Insgesamt ergeben sich dadurch ein sauberes Design, frei von PHP Code.
Dadurch wurde auch eine Programierlogik implementiert, mit der sich bedingte Ausgaben durchführen lassen. Vielleicht wird ja in der Zukunft in diesem Bereich noch etwas mehr kommen. Dann könnte man das Ganze auch J!Script nennen... schön!

Head

Der Headbereich (html) der Site
J! 1.5
<jdoc:comment>
@copyright Copyright (C) 2005 - 2006 Open Source Maters. All rights reserved.
@license GNU/GPL, see LiCENSE.php
</jdoc:comment>
<?php echo '<?xml version="1.0" encoding="utf-8"?' .'>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"htp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="htp://www.w3.org/1999/xhtml" xml:lang="{LANG_TAG}"
lang="{LANG_TAG}" dir="{LANG_DiR}" >
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="templates/_system/css/general.css" type="text/css" />
<link rel="stylesheet" href="templates/{TEMPLATE}/css/template_css.css"
type="text/css" />
<jdoc:tmpl name="loadcss" varscope="document" type="condition"
conditionvar="LANG_DiR">
  <jdoc:sub condition="rtl">
  <link href="templates/{TEMPLATE}/css/template_rtl.css" rel="stylesheet"
type="text/css" />
  </jdoc:sub>
</jdoc:tmpl>
</head>

Folgendes ist nur nötig, falls das Template PHP Code enthält. Joomla! 1.5 Templates sollten keinen PHP Code enthalten.
J! 1.0
defined( '_VALID_MOS' ) or die( 'Restricted access' );
J! 1.5 (wird bei Joomla! 1.5 Templates i.d.R NICHT benötigt)
defined( '_JEXEC' ) or die( 'Restricted access' );

Folgendes wird in Joomla! 1.5 NICHT mehr benötigt
J! 1.0
<?php if ( $my->id ) { initEditor(); } ?>

PathWay

Aus "PfadWeg" wird "Brotkrume" - jetzt als eigenständiges Modul (!)
J! 1.0
<?php mosPathWay(); ?>
J! 1.5
<jdoc:include type="module" name="breadcrumbs" style="-1" />

Module

So werden jetzt die Module geladen
J! 1.0
<?php mosLoadModules ( 'left', -2 ); ?>
J! 1.5
<jdoc:include type="modules" name="left" style="-2" />

Hier kommt Programm ! (inoffiziel heisst das glaub ich J!Script :D )
J! 1.0
<?php
if ( mosCountModules( 'right' ) ) {
    mosLoadModules ( 'right', -2 );
}
?>
J! 1.5
<jdoc:exists type="modules" condition="right">
    <jdoc:include type="modules" name="right" style="-3" />
</jdoc:exists>
 
//es geht auch z.B. folgendes:
<jdoc:exists type="modules" condition="user1 and user2" >

Content

So wird der Content ausgegeben
J! 1.0
<?php mosMainBody(); ?>
J! 1.5
<jdoc:include type="component" />
Bedingte Ausgabe
<jdoc:tmpl name="showComponent" varscope="document" 
     type="condition" conditionvar="PARAM_SHOWCOMPONENT">
  <jdoc:sub condition="1">
    <jdoc:include type="component" />
  </jdoc:sub>
  <jdoc:sub condition="0">
    &nbsp;
  </jdoc:sub>
</jdoc:tmpl>

Diverses

Das Datum
J! 1.0
<?php echo mosCurrentDate ('%m|%Y'); ?>
J! 1.5
<?php echo JHTML::Date( 'now', '%m|%Y' ); ?>

Die live_site
J! 1.0
<?php echo $mosConfig_live_site; ?>
J! 1.5
<?php echo $mainframe->getCfg('live_site'); ?>

Das aktuelle Template
J! 1.0
<?php echo $cur_template; ?>
J! 1.5
{TEMPLATE}

Neu

Neue Funktionen in Joomla! 1.5
J! 1.5
<jdoc:comment>
 
<jdoc:include type="head" />
 
<jdoc:include type="message" />
 
<jdoc:include type="modules" name="user3" style="-1" />
 
<jdoc:include type="module" name="breadcrumbs" />
 
<jdoc:exists type="modules" condition="newsflash" > und 
</jdoc:exists>
 
<jdoc:exists type="modules" condition="user1 or user2" >
 
<jdoc:exists type="modules" condition="user1 and user2" >
 
<jdoc:tmpl name="showComponent" varscope="document"
     type="condition" conditionvar="PARAM_SHOWCOMPONENT">
  <jdoc:sub condition="1">
    <jdoc:include type="component" />
  </jdoc:sub>
  <jdoc:sub condition="0">
    &nbsp;
  </jdoc:sub>
</jdoc:tmpl>
 
<jdoc:include type="modules" name="debug" style="-1"/>
 
< zurück
 


Suchmaschinenoptimierung mit Ranking-Hits PageRank Verifizierung www.nik-it.de
symmetrical