Jump to:

23358 Posts in 17875 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Action function Layout is rendering without Page template

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

Page: 1
Go to End
Author Topic: 691 Views
  • MonkeyBen
    Avatar
    Community Member
    25 Posts

    [SOLVED] Action function Layout is rendering without Page template Link to this post

    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?

  • MonkeyBen
    Avatar
    Community Member
    25 Posts

    Re: [SOLVED] Action function Layout is rendering without Page template Link to this post

    OK, found the answer: -

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

    Needs to be: -

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

    691 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.