Thursday 10 November 2005 5:00:33 pm
Hi John, one thing as I mentioned earlier is that your template code may become harder to read if you are determined to have clean XHTML. So if you are prepared to sacrifice some legibility of your template code you will have clean output. Looking at your file there are a couple of things I do differently to get the output looking the way I want it. I don't indent any of the template code, for example I don't indent {section}, {if}, {let}, {def} etc. So this:
{default}
{section}
{section}
<li></li>
{/section}
{/section}
{/default}
would look like this:
{default}
{section}
{section}
<li></li>
{/section}
{/section}
{/default}
I break (between) and (inside) sections, when you do a loop this is important as each item looped will start on a new line rather than starting at the end of the last item. So if you don't want this to happen:
<ul>
<li></li> <li></li> <li></li>
</ul>
You need to break either above or below your list item within your {section} tags, then preceding or following the section break again. eg.
<ul>
{section loop=...}
<li></li>
{/section}
</ul>
<ul>
{section loop=...}
<li></li>
{/section}
</ul>
Both of these should produce:
<ul>
<li></li>
<li></li>
<li></li>
</ul>
Also another thing to lookout for is extra tabs or spaces:
{section}[tab][tab]
[tab][tab]<li></li>
[tab][tab]
{/section}
Should be:
{section}
[tab][tab]<li></li>
{/section}
Another thing I often do is add a break at the end of a template, like an include template or line view template. This avoids the code below starting at the end of the previous line, it should start on a new line. So thats mostly what I do, however sometimes I don't get the expected result first time, this is where you need a little patience. Here is the code I would use for the page_head.tpl, this may not produce exactly the right output, I haven't tested it but it will come close, you just need to play with the spacing as I suggested above.
{default enable_help=true() enable_link=true()}
{let name=Path path=$module_result.path reverse_path=array()}
{section show=is_set($module_result.title_path)}
{set path=$module_result.title_path}
{/section}
{section loop=$:path}
{set reverse_path=$:reverse_path|array_prepend($:item)}
{/section}
{set-block scope=root variable=site_title}
{section loop=$Path:reverse_path}{$:item.text|wash}{delimiter} / {/delimiter}{/section} - {$site.title|wash}
{/set-block}
{/let}
<title>{$site_title}</title>
{section show=and(is_set($#Header:extra_data),is_array($#Header:extra_data))}
{section name=ExtraData loop=$#Header:extra_data}
{$:item}
{/section}
{/section}
{* check if we need a http-equiv refresh *}
{section show=$site.redirect}
<meta http-equiv="Refresh" content="{$site.redirect.timer}; URL={$site.redirect.location}" />
{/section}
{section name=HTTP loop=$site.http_equiv}
<meta http-equiv="{$HTTP:key|wash}" content="{$HTTP:item|wash}" />
{/section}
{section name=meta loop=$site.meta}
<meta name="{$meta:key|wash}" content="{$meta:item|wash}" />
{/section}
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta name="generator" content="eZ publish" />
{section show=$enable_link}
{include uri="design:link.tpl" enable_help=$enable_help enable_link=$enable_link}
{/section}
{/default}
This should produce this:
<title>Welcome to eZ publish</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-language" content="eng-GB" />
<meta name="author" content="eZ systems" />
<meta name="copyright" content="eZ systems" />
<meta name="description" content="Content Management System" />
<meta name="keywords" content="cms, publish, e-commerce, content management, development framework" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta name="generator" content="eZ publish" />
Hope this helps, let me know if you have any trouble. Cheers!
Pardon me while I burst into flames...
|