[TYPO3-mvc] Blog example: Number of comments
Joerg Schoppet
joerg at schoppet.de
Mon Jul 27 22:07:00 CEST 2009
Hi,
Steffen Ritter schrieb:
> Just implement a getter for commentCount ;)
> return count($this->comments)
I see three possibilities:
1. mentioned by Steffen
Implement a method in class Post, which ist called getCommentCount() with the body written above.
Then you can do in the template {post.commentCount}
But I think this is not the way OO and the implementation of fluid should be used.
2. in the action method, just assign an additional var like $this->view->assign('commentCount', count($post->getComments()));
Then you can do in the template {commentCount}
3. What you mentioned with an own viewhelper.
I would prefer solution 2. Solution 3 seems to be to "heavy".
Joerg
More information about the TYPO3-project-typo3v4mvc
mailing list