0

I'm currently working with Symfony and I was wondering how to change the default partial.

In my components.class.php, I have my executeWhatever() that calls my _Whatever.php. But I would like to add a condition in my executeWhatever() so I can do something like this:

public function executeWhatever(sfWebRequest $request)
{
   if (myCondition)
      usePartial('_firstPartial.php');
   else
      usePartial('_secondPartial.php');
}

I could easily includePartial(); directly into my _Whatever.php but I have some Doctrine requests that I would like to make according to myCondition.

I've found that I could use includePartial() in my executeWhatever() except that it's still including my _Whatever.php by default.

So the question is simple: how can I do to change the default partial used by my component method executeWhatever() ?

MaximeBernard
  • 1,090
  • 1
  • 19
  • 33

1 Answers1

1

You can't change the partial, but try these solutions: Symfony: Is it possible to setTemplate for components?

Community
  • 1
  • 1
Darmen Amanbay
  • 4,869
  • 3
  • 29
  • 50
  • Thanks for the link ! So... Few questions: 1) "return sfView::NONE;" will remove the default partial right ? 2) What does he mean by "render the partial manually" witi the PartialHelper ? 3) I was also thinking about overriding sfComponnents class What do you think about it ? – MaximeBernard Apr 05 '11 at 23:07
  • 1) `return sfView::NONE`will just render nothing; 2) `render the partial manually` means that you can load `PartialHelper` helper in component and use `get_partial()` function there; 3) I don't think it's necessary unless you'll use it wisely in your project – Darmen Amanbay Apr 06 '11 at 09:26