Cheers
Nicolaas Thiemen Francken
Director Sunny Side Up Ltd
skype: nicolaasthiemen
within NZ phone 0800 771 777
overseas call +64 274 771 777
n...@sunnysideup.co.nz
www.sunnysideup.co.nz
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.16.10/1159 - Release
> Date: 29/11/2007 11:10 a.m.
>
>
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.16.10/1159 - Release Date: 29/11/2007
11:10 a.m.
The problem is that at the moment there are certain things that should
be simple, but aren't. For example:
- $Title <% control Children %>$Outer.Title - $Title<% end_control %>
- $Author.FirstName.LowerCase
- <% if Colour != 'red' %>Not Red<% end_if %>
Jamie
Well principally objects are threatened like normal variables in Smarty - I
don't understand exactly what you mean by "second class citizens".
> E.g. how would you achieve this construct in smarty:
> $myViewableData->customise(array(
> 'MyCustomProperty' => 'foo',
> 'MyCustomObject' => $manySubproperties
> ))->renderWith('LayoutTempate','MainTemplate');
Hmm... if I understand the code right, I does nothing more than registering
'foo' as $MyCustomProperty and the object/variable $manySubproperties as
$MyCustomObject for the template and render it then with the templates
'LayoutTempate' or 'MainTemplate', right!?
In Smarty you would do something like this
$smarty->assign('MyCustomProperty', 'foo');
$smarty->assign('MyCustomObject', $manySubproperties);
OR
$smarty->assign(array(
'MyCustomProperty' => 'foo',
'MyCustomObject' => $manySubproperties));
// check if LayoutTemplate exists
$smarty->fetch('LayoutTemplate');
// otherwise do
$smarty->fetch('MainTemplate');
So specifying more possible templates at once is not possible by default,
but we could easily reuse the existing code to implement this.
> i'm not sure about the performance-implications of registering objects
> with the templating engine,
> and if it supports nesting them - any ideas?
Registering variables or objects for the template does nothing else than
assigning them to some array ($smarty->vars['xyz'] = $value). So there
shouldn't be performance problems. What do you mean by nesting them?
How does caching work at the moment? Is there really any caching or is there
just a compilation of the templates? At least I cannot see anything else by
looking at "silverstripe-cache" directory. Smarty would support compilation
AND caching of whole documents which would result in a big performance boost
for SilverStripe powered sites (since most of the pages are static or change
seldom nevertheless).
I would suggest to outsource all the template parsing, compiling and caching
stuff to (for example) Smarty and leave the rest of the logic in SSViewer
and ViewableData. So we could combine the power of two worlds. SilverStripes
features like templating and the parsing power of Smarty with it's
modularized architecture and extendability.
I haven looked at it in detail but I think it wouldn't be much work to
achieve this.