[TYPO3-ect] SmartyView & lib/div view in general
Elmar HInz
elmar.hinz at team.MINUS.red.DOT.net
Tue Feb 20 08:57:00 CET 2007
Hi Thomas,
thanks for research on smarty.
>
> I think this is a different view/templating-paradigm then what I'm used
> with smarty, where we have a (cleaner?) cut between controller & view by
> (regularly) only passing static data in form of variables and arrays.
> This is what most of the smarty functionality is working on, like
> foreach and stuff.
I have observed at least three philosophies.
1. That of lib/div is very simple and analogous to the template
engine of the ZEND framework. The data are located within our
very own object.
2. From the first glance Smarty comes with it's own object, you need to
instanciate and programms the loops within the template, just like
lib/div. So templates are similar complex.
3. Other Engines I have observed programm the loops within the object.
Again you need to extend it from the engines library object and
logically you also need to instanciate it. Templates are as simple
as the classical T3 templates. The designer has few power. He depends
completely on the logic the programmer has done in the object. So the
templates are not very flexible to use.
>
> You CAN use objects in Smarty, but in this case again the biggest con to
> php-templating would again count for a SmartyView: too much power in the
> hand of the template-designer/coder + unsexy syntax.
>
As discussed above 1. and 2. versus 3./classic T3 templates you have to
decide between template based logic and object based logic. My customers
regularly want a lot of flexibility, even for the price that they have to
think a little more. In this cases the type 1., 2. is the right choice.
Type 3./classic T3 templates are not flexible enough.
> What I want to do in a clean way is to get the data out of the model, I
> tried e.g. the iterator with "$this->_iterator->getArrayCopy()", but
> that's quite dirty I guess.
It's unclean because you acces a private (_iterator) variable.
$this->getArrayCopy() would be right.
$this->getHashArray() is an alias I like better. It meets with the 6
systematical data structure names I defined in div lately:
http://typo3.org/extensions/repository/view/div/0.0.9/info/class.tx_div.php/
>
> I also thought about directly passing the static data to the render
> function, but this would tie the controller to smarty, making it unable
> to use the phpView. There should be a universal interface for that, have
> I overseen it?
There are many alternative ways to use lib/div. It's object orientated. I
can't judge what impacts it may have to tie the controller to something,
without knowing details. As the controller is the starting point that is
called instanciated by USER / USER_INT I can't even imagine how that could
work.
In generally I think it should be possible to instanciate an object of the
smarty type (or any other templating engine) from within a general
tx_lib_object and to pass the data to it. I expect there is no special
interface needed to do so. You will get the passed string back from the
smarty object and can proceed the object chain i.e. doing translations.
>
> Can any of you give me a hint on accessing the data in a cleaner way?
Regards
Elmar
More information about the TYPO3-team-extension-coordination
mailing list