[TYPO3-mvc] get controller context inside template

Sebastian Kurfürst sebastian at typo3.org
Sat Oct 24 15:07:26 CEST 2009


Hi Fernando,

> But i'm using the partian inside the layout not in the sections, so whith 
> you way i'll have to modify every template to pass the action name. I 
> think that it isnt very clean
OK, That's an issue :-)

Alternative: Write a custom ViewHelper which you can use like this:
{namespace foo=Tx_Foo_ViewHelpers}
<f:link.action action="{foo:currentAction()}">...</f:link.action>

Then, the VH looks like this:
class Tx_Foo_ViewHelpers_CurrentActionViewHelper implements
...AbstractViewHelper {
  public function render() {
  return
     $this->controllerContext->getRequest()->getControllerActionName();
  }
}

Greets,
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list