How can I get the action name inside a template? The template is actually a partial.
Asked
Active
Viewed 6,191 times
2 Answers
10
You should try :
$sf_params->get('action')

Pascal
- 1,288
- 8
- 13
-
This is probably better because i think its directly tied to the initial action parsed by the router... – prodigitalson Dec 09 '11 at 17:11
-
is that an instance of sfParameterHolder? – prongs Dec 09 '11 at 17:18
-
`$sf_request sfRequest` `$sf_context sfContext` `$sf_user myUser` `$sf_params sfParameterHolder` – Pascal Dec 09 '11 at 17:42
4
The sfContext
instance should be automagically exposed in the view layer as $sf_context
so you could do: $sf_context->getActionName()
.
However i think this may not necessarily be the action youre looking for, because i think it may be the current action being processed which if its a partial for a component would be the component's action. Not 100% on that as ive never had a need to use/investigate :-)

prodigitalson
- 60,050
- 10
- 100
- 114
-
can you tell me what variables are exposed where? like sfContext, sf_user, ...? thanks for quick reply btw. :) – prongs Dec 09 '11 at 16:43
-
and it says `Notice: Undefined variable: sfContext in /var/www/weblog/apps/backend/modules/poster/templates/_form.php on line 5 Fatal error: Call to a member function getActionName() on a non-object in /var/www/weblog/apps/backend/modules/poster/templates/_form.php on line 5` so, no – prongs Dec 09 '11 at 16:50
-
1