开发者

How to change the default partial in Symfony?

开发者 https://www.devze.com 2023-02-22 05:18 出处:网络
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

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消