Search code examples
phpsymfony1

In Symfony ( PHP ), what is the path of setTemplate method?


I am using the following code in action class of a module XYZ:

$this->setTemplate("abc.php");

In which directory, it is trying to find abc.php?


Solution

  • See http://www.symfony-project.org/gentle-introduction/1_4/en/06-Inside-the-Controller-Layer#chapter_06_sub_action_termination. This documentation page contains comprehensive list of possible template names.

    To be clear. Call

    $this->setTemplate("abc");
    

    will force Symfony to render template module/templates/abcSuccess.php if coressponding action method returns sfView::SUCCESS or nothing.

    module/templates/abcError.php will be rendered if your action will return sfView::ERROR.

    Also if your action is terminated with return 'SomeString'; then module/templates/abcSomeString.php is to be rendered.