i`m trying to call a ViewHelper Function from within a Controller in Typo3 (to add some additional header data)
Base is the Yag Gallery.
I edited the ItemListController.php and added the following:
$pager = $this->extListContext->getPagerCollection();
$prevLinkUid = $pager->getPreviousPage();
$arg = Tx_YAG_ViewHelpers_Namespace_GPArrayViewHelper::render([page:$prevLinkUid], $pager)
$test = '<link rel="test" href="' . $arg . '">';
$this->response->addAdditionalHeaderData($test);
The addAdditionalHeaderData function works well with other data (e.g. $prevLinkUid
, so this part is functioning well).
If i understand the syntax of GPArrayViewHelper::render correctly, i need a pageUid as first argument and the pagerCollection as second argument (derived from this call within Resources/Private/Partials/Pager/Default.html
<extlist:link.action controller="{controller}" action="{action}" arguments="{extlist:namespace.GPArray(object:'{pagerCollection}' arguments:'page:{pager.previousPage}')}"><span><</span> </extlist:link.action>
)
However - if i try this Controller my page won't render, so i assume there is something wrong with the php code / function call, maybe even the syntax of the key value pair/first argument? Sorry, i'm not a professional in php
Any ideas how can i achieve this? I read that it may be difficult to use ViewHelpers from within other controllers?