MaximeBernard
MaximeBernard

Reputation: 1100

How to change the default partial in Symfony?

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() ?

Upvotes: 0

Views: 213

Answers (1)

Darmen Amanbay
Darmen Amanbay

Reputation: 4881

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

Upvotes: 1

Related Questions