[TYPO3-mvc] ViewHelpers Setting/Updating variables restriction
Robert Vock
robert.vock at 4wdmedia.de
Tue Oct 19 14:40:35 CEST 2010
Hello,
I just started using extbase and fluid for a work-project.
I was used to Smarty and a Custom (smarty-like) Templating Engine before, and I have to say, it takes some time to get used to fluid.
It's a bit too restrictive for my taste :)
I dislike the restriction, that you can't set variables in the template and check them again.
If I iterate over an array (or an array-like structure), I would like to mark the first entry (which does not necessarily has the key 0) with an extra css class name.
I couldn't find any way doing this with fluid, except modifying the array within the controller (which violates the separation of Controller and View) or writing an own ViewHelper. Is there any better/easier way?
This seems to be a bit complex for such a simple operation. In Smarty this is just done with setting a variable to false before the loop, checking it within the loop and setting it to true...
I also couldn't find a way to call sections recursively. I have a tree-structure as an array.
Each array entry has a key "name" and can have a key "children" with children for this entry.
I thought of defining a section "renderTree" and call it recursively:
<f:section name="renderTree">
<ul>
<f:for each="tree" as="entry">
<li>{entry.name}
<f:if "{entry.children}">
<f:then>
<f:alias map="{tree: entry.children}">
<f:render section="renderTree" />
</f:alias>
</f:then>
</f:if>
</li>
</f:for>
</ul>
</f:section>
<!-- controller only set the variable $tree -->
<f:render section="renderTree" />
This is not possible, because updating variables with the AliasViewHelper is not possible.
Is there any way to write comments, that do not appear in the rendered source?
I like to comment my templates, but I do not like it when all visitors of my page can see them.
That's why I wrote a CommentViewHelper, which does not render it's children. But it is a lot of code to write for simple comments:
<v:comment>This comment will not appear in the HTML-Source</v:comment>
In Smarty:
{* This comment will not appear in the HTML-Source *}
Well, it is still possible to name the helper just CViewHelper to get <v:c> tags...
But anything built-in would have been nice :)
Have a nice day,
Robert
More information about the TYPO3-project-typo3v4mvc
mailing list