2011-05-03 49 views

回答

5

参见http://www.symfony-project.org/gentle-introduction/1_4/en/06-Inside-the-Controller-Layer#chapter_06_sub_action_termination。此文档页面包含可能的模板名称的完整列表。

要清楚。呼叫

$this->setTemplate("abc"); 

将迫使Symfony的呈现模板module/templates/abcSuccess.php如果coressponding操作方法返回sfView::SUCCESS有或全无。

module/templates/abcError.php将会呈现,如果你的行动将返回sfView::ERROR

此外,如果您的行动终止于return 'SomeString';那么module/templates/abcSomeString.php将被呈现。

6

相应的路径是templates目录,该目录与编辑actions.class.php文件的目录actions平行。

在文件中/path/to/my/module/actions/actions.class.php,如果你这样做:

$this->setTemplate("index");

相应的模板文件将位于:

/path/to/my/module/templates/indexSuccess.php

当然,这是假设的动作成功完成;失败后,处理是不同的,并取决于您的实施。

另外值得注意:

如果不设置使用手动$this->setTemplate($foo)一个模板,模板名称按照惯例确定。对于动作功能executeHomepage(sfWebRequest $request), ,模板homepageSuccess.php将按照惯例显示(同样,除非另有说明,否则使用setTemplate)。

0

根据API Documentation

任何时刻i写:

$这 - > setTemplate( 'ACTION_NAME', 'MODULE_NAME');

相关问题