Olle Härstedt
Olle Härstedt

Reputation: 4020

How do I access GET/POST from a view helper?

I have a custom content element which uses a view-helper that inherits from link action. I want to use specific CSS when this link is "active". One way to do this would be to read _GET and check for link variables. Can I access _GET in a sane way from a view-helper? Or is there a better way?

Maybe this is impossible because the output of the view-helper will be cached...

I could of course access $_GET directly, but will this work with RealUrl?

Upvotes: 0

Views: 746

Answers (1)

biesior
biesior

Reputation: 55798

Of course you can, the same way as you would do it within controller:

$fooInGet    = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('foo');
$barInPost   = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('bar');
$zeeAnywhere = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('zee');

Upvotes: 5

Related Questions