[TYPO3-mvc] Fluid cObject into a view helper
Karsten Madsen
karsten at k20.dk
Wed Feb 10 09:55:42 CET 2016
Hi Ludwig
Thank you for your quick reply, your a ninja. And you brought me to the right way. Now it works after fixing my viewhelper too.
Now I get the error Required argument "images" was not supplied.
So I found that it was my viewhelper that needed a little twist from, because I dont send the data as a parameter:
class ImageViewHelper extends AbstractViewHelper {
/**
* @param string $images
* @return string
*/
public function render($images) {
$imagearray = explode(':',$images);
$count = count($imagearray);
$rand = rand(1,$count);
$imageNumberInArray = $rand - 1;
return $imagearray[$imageNumberInArray];
}
}
to this:
class ImageViewHelper extends AbstractViewHelper {
/**
* @return string
*/
public function render() {
$images = $this->renderChildren();
$imagearray = explode(':',$images);
$count = count($imagearray);
$rand = rand(1,$count);
$imageNumberInArray = $rand - 1;
return $imagearray[$imageNumberInArray];
}
}
Venlig hilsen
K20 - Karsten Madsen
______________________________
Email: karsten at k20.dk
______________________________
> On 10 Feb 2016, at 09:35, Ludwig Rafelsberger <ludwig.rafelsberger at gmx.at> wrote:
>
> Try
> <header class="site-header full-size-left" style="background-image: url({f:cObject(typoscriptObjectPath: 'lib.topimage', data:{template:'default'}) -> cmb:image()})">
>
> When chaining inline ViewHelpers, do not close and reopen curly braces.
>
> Cheers,
> Ludwig
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
More information about the TYPO3-project-typo3v4mvc
mailing list