Re: [SMARTY] Class::method() in if tags
| From: | Jochem Maas | Date: | Thu, 29 Apr 2004 19:41:03 +0000 |
| Subject: | Re: [SMARTY] Class::method() in if tags | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11328@lists.php.net to get a copy of this message | ||
BTW: thanks to everyone for the feedback on this.
boots wrote:
[snip]David Förster wrote:unidentified{if Auth::logged_in()} produces Fatal error: Smarty: [in main.tpl line 115]: syntax error:that in thetoken '::logged_in()' Can I use a different syntax or are there any plans to supportthis would enable static method-calls inside if-functions:future?
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