tanujdave
tanujdave

Reputation: 237

how to get template name in symfony

I want to get my template name in my layout.php. please help me

<?php $module_name = $sf_context->getModuleName(); ?>

i'm using this above code to get module name, but how to get my current template name.

Upvotes: 1

Views: 1481

Answers (2)

domi27
domi27

Reputation: 6923

So symfony is a MVC framework your question belongs to sfView

/* layout.php e.g. */
var_dump($this->getTemplate());

See :

Upvotes: 0

Andreu Ramos
Andreu Ramos

Reputation: 2908

if you set the template in your action with the setTemplate() function you can just get the template name with getTemplate(). If you did¡nt assign a template in the action the get Template function will return null.

If you didn't modify the template associated to an action (by default the execute[Action] has a [action]Success.php template) you can make a function like this in your action:

$funcName = $this->getActionName();
--> find the first uppercase letter there starts the function name.
--> $new String() = [first letter of name in lowercase] . [rest of the name]
--> $String = string . "Success.php";

i'm not advanced enough in php to tell the exacte code but that's the algorithm.

Hope it helped you, good luck;

Upvotes: 1

Related Questions