Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony: Is it possible to setTemplate for components?

Tags:

php

symfony1

There’s no setTemplate() for components! I know but maybe there is another way to do it ?

(The question seems to be about a php framework: http://www.symfony-project.org/)

like image 430
Andrey Avatar asked Oct 23 '09 11:10

Andrey


1 Answers

There is no setTemplate method on sfComponents. You essentially have 3 options:

  1. Name your component the same as the partial you'd like the component to render. This may not be possible if you have multiple components you'd like to share the same template.
  2. Create a partial with the same name of your component and include the partial there. That is, if you had a component with an executeFoo() method that you wanted to render the _bar.php template, simply call include_partial('bar', $vars) inside of _foo.php.
  3. Load the PartialHelper and render the partial manually inside of the components execute method and have the component return sfView::NONE.
like image 97
Jeremy Kauffman Avatar answered Sep 19 '22 15:09

Jeremy Kauffman