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

[SOLVED] Action function Layout is rendering without Page template


Reply

2 Posts   751 Views

Avatar
MonkeyBen

7 March 2012 at 5:55am Community Member, 25 Posts

I have done a work around for the following problem in the past but I think I need to find a proper solution now.

My problem is this

1. I have a page type of, e.g. ParentPage
2. I have other page types e.g. ChildPage1 & ChildPage2, which extend ParentPage

I have put an action function in the ParentPage that I want all child page types to access, e.g. function addnote() as shown here: -

function addnote()
{
   $data = array(...);
   return $this->customise($data)->renderWith("ParentPage_addnote", "ParentPage");
}

I have a main template called ParentPage.ss and in the Layout folder I have a layout template called ParentPage_addnote.ss

Now I have setup a few pages of the ChildPage1 type and go to it by domain.com/childpage/addnote the function works and the ParentPage_addnote.ss layout is rendered, but it is rendered without the page template shell ParentPage.ss

Where am I going wrong?

Avatar
MonkeyBen

7 March 2012 at 11:50pm Community Member, 25 Posts

OK, found the answer: -

return $this->customise($data)->renderWith("ParentPage_addnote", "ParentPage");

Needs to be: -

return $this->customise($data)->renderWith(array("ParentPage_addnote", "ParentPage"));