Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Set which Template to use


Reply


3 Posts   606 Views

Avatar
animasola

Community Member, 121 Posts

2 November 2010 at 12:56am

Would it be possible to select which template file (.ss) to use or does each page type have to be a corresponding pair? By that I mean, does Page.PHP only correspond to Page.SS or can we dictate it within the PHP file?

I want to have two template files for my Page.PHP since I will be using a multi-language set-up.

Can anyone tell me if this is possible? Thank You.

Avatar
mmh

Community Member, 24 Posts

2 November 2010 at 1:18am

Try to use the renderWith() function.

return $this->renderWith('MyTemplate');

Wiki: http://doc.silverstripe.org/templates#calling_templates_from_php_code
Api: http://api.silverstripe.org/2.4/sapphire/view/ViewableData.html#methodrenderWith

Avatar
cuSSter

Community Member, 56 Posts

2 November 2010 at 11:56pm

Yes, it is very possible. I was able to implement it to object and pages in our conversion testing. :)