I want to get my template name in my layout.php. please help me
<?php $module_name = $sf_context->getModuleName(); ?>
i'm using th开发者_如何学Cis above code to get module name, but how to get my current template name.
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;
So symfony is a MVC framework your question belongs to sfView
/* layout.php e.g. */
var_dump($this->getTemplate());
See :
- http://www.symfony-project.org/api/1_4/sfView#method_gettemplate
精彩评论