开发者

Symfony question. How to use get_partial inside the action.class?

开发者 https://www.devze.com 2023-02-23 11:59 出处:网络
When I do this: public function executeGetHTML(sfWebRequest $request) { **$pageContent = get_partial(\'mypage2\'); **

When I do this:

public function executeGetHTML(sfWebRequest $request)
{
  **$pageContent = get_partial('mypage2'); **
}

I get this:

Call to undefined function get_partial()

so, how to switch it on? I tried sfLoader::开发者_JAVA技巧loadHelpers('Partial'); but it says sfLoader is undefined.. :(


You need to use $this->getPartial() in your actions.


Above answers didn't work for me

I've tried:

sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
$html = get_partial('partial_name');

And it works.

You have to call get_partial function in action class without $this keyword.


And if it still doesn't work. Check if you have:

all:
 .settings:
  #....
  standard_helpers:       [Partial]

In your config/settings.yml file


Try to load the 'partial' helper.Something like this :

sfContext::getInstance()->getConfiguration()->loadHelpers('Partial);

And then try:

this->get_partial('name of your partial');

Note: Provided check the symfony version.If it is 1.4 , it doesn't invoke partial helpers by default.And so we need to the use the code above.

0

精彩评论

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

关注公众号