Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Adding a new page below another page

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1033 Views
  • infinity
    Avatar
    Community Member
    3 Posts

    Adding a new page below another page Link to this post

    Hi,

    I'm adding a new page using a form on the front page (similar to the tutorial for adding a poll result). I got it working to just add the page. What I'd like to do now is add the page below an existing page. Can anybody suggest how I do this.

    Here is the current code that just adds the new page at the top of the hierarchy:
    function addMyItem($data, $form) {
    $my_item = new MyItem();
    $form->saveInto($my_item);
    $my_item->write();

    Director::redirectBack();
    }

    Thanks,
    Bruce

  • infinity
    Avatar
    Community Member
    3 Posts

    Re: Adding a new page below another page Link to this post

    I've figured out how to do this:

    function addMyItem($data, $form) {
    $my_items_holder_set = DataObject::get('MyItemsHolder');
    $my_items_holder = $my_items_holder_set->First();
    $my_item = new MyItem();
    $form->saveInto($my_item);
    $my_item->setParent($my_items_holder);
    $my_item->write();

    Director::redirectBack();
    }

    1033 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.