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 includePartia开发者_JS百科l(); 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() ?
You can't change the partial, but try these solutions: Symfony: Is it possible to setTemplate for components?
精彩评论