21285 Posts in 5732 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 473 Views |
-
renderWith()

9 July 2012 at 4:36am
Hi everyone,
I have a Portfolio page type (PortfolioPage.ss) that in one condition needs to render as a Home page (HomePage.ss). In my PortfolioPage.php controller, I have:
public function index() {
return $this->renderWith(array('HomePage', 'Page'));
}(condition will be added later)
I'm using the GET var 'debug_request' flag, and I can see this:
Debug (line 202 of SSViewer.php): Final template selections made: array (
'Layout' => '.../themes/oms/templates/Layout/HomePage.ss',
'main' => '../themes/oms/templates/Page.ss',
)Which seems correct. However, in the rendering there's no data passed to HomePage.ss. Also, the $ClassName var is still 'PortfolioPage'.
This is in 2.4.7. Could anyone advise what the final step is to actually render the Portfolio page as Home page? I think I'm close.
Thanks!
Wilson -
Re: renderWith()

9 July 2012 at 4:01pm
Which seems correct. However, in the rendering there's no data passed to HomePage.ss. Also, the $ClassName var is still 'PortfolioPage'.
Of course $ClassName is still portfolio as all you're doing is changing the 'view' not the data. If you wish to also override data then using customize.
public function index() {
return $this->customise(new ArrayData(array(
'ClassName' => 'HomePage'
)))->renderWith(array('HomePage', 'Page'));
} -
Re: renderWith()

9 July 2012 at 4:11pm Last edited: 9 July 2012 4:11pm
Ah, I see! Thanks Willr! I had played with 'customise' earlier but couldn't quite get it. Thanks. Best, Wilson
| 473 Views | ||
|
Page:
1
|
Go to Top |


