我想在我的layout.php中获取我的模板名称。请帮我如何在symfony中获取模板名称
<?php $module_name = $sf_context->getModuleName(); ?>
我使用上面的代码来获取模块名称,但如何获得我当前的模板名称。
我想在我的layout.php中获取我的模板名称。请帮我如何在symfony中获取模板名称
<?php $module_name = $sf_context->getModuleName(); ?>
我使用上面的代码来获取模块名称,但如何获得我当前的模板名称。
如果您在setTemplate()
函数中将模板设置为您的操作,则只需使用getTemplate()
即可获取模板名称。如果您没有在操作中分配模板,get Template函数将返回null。
如果没有修改相关联的动作模板(默认情况下,执行[动作]有[动作] Success.php模板),你可以做这样的功能在你的行动:
$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";
我不够先进的PHP来告诉exacte代码,但这是算法。
希望它能帮助你,祝你好运;
所以symfony的是一个MVC框架你的问题属于sfView
/* layout.php e.g. */
var_dump($this->getTemplate());
参见: