6

How can I get the action name inside a template? The template is actually a partial.

prongs
  • 9,422
  • 21
  • 67
  • 105

2 Answers2

10

You should try :

$sf_params->get('action')
Pascal
  • 1,288
  • 8
  • 13
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
    its `$sf_context` not `sfContext`... thats the class name :-) – prodigitalson Dec 09 '11 at 17:10