
| Templates 1.0 -> 1.5 |
|
|
|
| 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.<? 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.
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.
--------------------------------------------------- Die Installer xml DateiDie Ä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..
<mosinstall type="template">
...
</mosinstall>
<install type="template">
...
</install>
Danach sollte es sich installieren lassen. Die index.phpHier sind etwas mehr Änderungen nötig. Insgesamt ergeben sich dadurch ein sauberes Design, frei von PHP Code. Head
Der Headbereich (html) der Site
<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.
Folgendes wird in Joomla! 1.5 NICHT mehr benötigt
<?php if ( $my->id ) { initEditor(); } ?> PathWay
Aus "PfadWeg" wird "Brotkrume" - jetzt als eigenständiges Modul (!)
<?php mosPathWay(); ?>
<jdoc:include type="module" name="breadcrumbs" style="-1" /> Module
So werden jetzt die Module geladen
<?php mosLoadModules ( 'left', -2 ); ?>
<jdoc:include type="modules" name="left" style="-2" />
Hier kommt Programm ! (inoffiziel heisst das glaub ich J!Script :D )
<?php if ( mosCountModules( 'right' ) ) { mosLoadModules ( 'right', -2 ); } ?>
<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
<?php mosMainBody(); ?>
<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"> </jdoc:sub> </jdoc:tmpl> Neu
Neue Funktionen in Joomla! 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"> </jdoc:sub> </jdoc:tmpl> <jdoc:include type="modules" name="debug" style="-1"/> |
| < zurück |
|---|










