[TYPO3-mvc] get controller context inside template

Fernando Arconada falcifer2001 at yahoo.es
Sun Oct 25 10:31:43 CET 2009


Sebastian,

Your code works with some fixes :-) but i realized that i cant have 
namespaces with more than one letter
- {namespace z=Tx_foor_ViewHelpers} works
- {namespace za=Tx_Mytube_ViewHelpers} throws exception :#1224254792: 
Namespace could not be resolved. This exception should never be thrown! 
27 Tx_Fluid_Core_Parser_TemplateParser::handler_objectAccessor
(Tx_Fluid_Core_Parser_ParsingState, "z", "a:currentAction()", "")

Shakespeare: To bug or not to bug?


Greets,

Fernando

El Sat, 24 Oct 2009 15:07:26 +0200, Sebastian Kurfürst escribió:

> 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