[TYPO3-50-general] Beer3 - Array Syntax and View Helpers

Daniel Pšötzinger nospam at nospam.de
Fri Oct 31 20:56:41 CET 2008


Sebastian Kurfürst schrieb:
> Hi Daniel,
> 
>>> As values, in case you want to write a string parameter, you have to
>>> quote it. There is _no_ parsing inside the string parameter, so you
>>> cannot use a variable inside a string parameter. (Example: {parameter1:
>>> 'this is a string with nothing parsed inside'})
>>> In case you want to output the contents of a variable there, use the
>>> following: {parameter2: post.id} - so this is as it is in JS.
>>> You can as well use arrays as values, so the nesting of arrays inside
>>> each other is easily possible.
>>
>> What about accessing methods of the presentationmodel and/or the view
>> itself?
> I don't fully understand what "methods of the presentation model" are in 
> this context. Could you clarify this? :-)
> 
> Concerning access to view methods: I'd rather forbid this at the moment, 
> as I think it is more easy and clean to write custom view helpers for 
> this (which is really easy to do anyways). However, after we started 
> playing around with the templating when it is working, if we still 
> notice that we need such a functionality, we can think about 
> implementing it.

Well but a common use of the viewclass itself is to have methods related 
to "placing pixels on the screen" therefore calling viewmethods its as 
clean as accessing membervariables. Otherwise there is the risk of 
missusing viewHelpers. But as you said trying gives the experience there.

Some words to presentationModel: It has some pros:
*Its a way to get some displaylogic of of the view
* Its a way to save the viewstate independed from the related domainmodel.
* Often the view has diffrent requirements than the related domainmodel: 
So the presentationModel has the missing methods and properties. So 
there is no reason to make the domainmodel "dirty" just because of some 
viewrequirements.

As I would use it for the blog example:

$postPresentationList is a collection of "postPresentationModels" 
instead of the "post" Domainmodel.

$view->setListModel($postPresentationList)

----
class postPresentationModels
.... public function getSomeFancySpecialTitleForTheWebsite() {
         return $this->post->getTitle().'-Fancy-';
      }



Therefore I would like to call also methods in the template. In this 
case something like:
<f3:for each="{blog.listItems}" as="listItem">
{listItem.getSomeFancySpecialTitleForTheWebsite()}
</f3:for>



what do you think?


More information about the TYPO3-project-5_0-general mailing list