简体   繁体   中英

Symfony 1.4 - set template for component / partial

I'm trying to set a different template for components/partials, but nothing works. Here is the problem, the pattern is in another folder, not a folder module. Can I somehow set the template for a component/partial from another folder?

If your component needs to return a specific partial which is in a different module then this works:

return get_partial('anotherModule/partialName', ['parameterName' => $parameterValue]);

Be aware of that if you used $this->setVar('name', 'value') then this won't be available in the partial. So you have to pass them too:

$this->setVar('parameterName2', 'parameterValue2');
[..]

return get_partial('anotherModule/partialName', [
    'parameterName1' => $parameterValue1,
    'parameterName2' => $this->getVar('parameterName2'),
]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM