[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-general
Subject:    Re: [SMARTY] Class::method() in if tags
From:       Jochem Maas <jochem () iamjochem ! com>
Date:       2004-04-29 19:41:03
Message-ID: 40915A4F.70105 () iamjochem ! com
[Download RAW message or body]

BTW: thanks to everyone for the feedback on this.

boots wrote:

>>>David Förster wrote:
>>>
>>>>{if Auth::logged_in()}
>>>>produces
>>>>Fatal error: Smarty: [in main.tpl line 115]: syntax error:
>>
>>unidentified 
>>
>>>>token '::logged_in()'
>>>>
>>>>Can I use a different syntax or are there any plans to support
>>
>>that in the 
>>
>>>>future?
>>
>>this would enable static method-calls inside if-functions:
>>
> 
> 
> [snip]
>  

> 
> Do we want to do this? 

yes - IMHO

> Are template designers concerned between the
> differences between class methods and object methods? 

not really, but atleast lets the programmer decide what he want to put 
in the template. besides CSS should be used for visual markup (if were 
talking 'truely' graphic designers) - and you can't argue with Tim 
Berners-Lee ;-)

> If Auth is used
> as a registered object (class would also work) this problem goes away
> and no new syntax is introduced.

but your manual says:

"a registered object cannot be looped over or assigned in arrays of 
objects, etc." - which really sucks

> 
> As for derefrenced objects, the same notion applies: is there a need to
> reference arbitrary positions in an object hierarchy? 

you give a pretty good example below!

> Is this something
> that designers should be concerned about (ie. should designers have to
> know the application object model or should they be given 'simple'
> template tools/structure?) 

if a 'designer' is making use of the presentation logic - rather than 
tweaking/adding/deleting the HTML inbetween - then yes they should be 
concerned about the object model (or whatever datastructures are available)

> Personally I pass a single "payload" to my
> main template and then dynamically included templates which are passed
> the appropriate portions of the total payload. That way, each template
> is at the "right" scope.

which is a perfect situation where a single complex object could be used 
- 'getting' values from it to pass to sub templates.

personally I don't let designers anywhere near a template - they can 
tweak the CSS and images till they go blue in the face but the template 
are mine ;-) (i.e. they contain only structural markup - usually they 
are very generic and contain mostly logic)

don't get me wrong I think Smarty is a really great tool for medium 
sized onward PHP (I reckon its overkill for _really_ small sites and 
very large project probably have requirements that put smarty out of the 
picture) BUT.... I think the emphasis on 'template engine' & seperating 
the designer / programmer role is causing:

a, possible confusion
b, people to be putoff Smarty unnecessarily.

by no means stop trying to develop a tool that allow developers to pass 
simple template files to designers but lay some more emphasis on the 
seperation of logic issue (maybe template engine is not the best 
description? mostly because the term applie equally to PHP itself, so 
maybe something like 'presentation engine' or possibly use the word 
'module' as it implies more of a plugable nature than engine which is 
something pretty core to a system - to my mind Smarty is very plugable - 
you just drop it in some where and start using it, i.e. there is no need 
to rewrite what you have just to begin incorporating it)

and please don't forget the crazies(TM) like myself who write templates 
as evil as their php scripts and would love to use static and 
dereferenced syntax as well as the possibility to pass complex params to 
functions e.g.

{if $Obj->getField( $CurFieldName )->typeIs(Field::INTEGER | Field::FLOAT) }

I know that this is PHP5 stuff - so don't consider it a gripe!

I would be very interested to know what the Smarty teams plans/ideas 
regarding PHP5.

> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Search - Find what you’re looking for faster
> http://search.yahoo.com
> 

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic