17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 947 Views |
-
Adding a new page below another page

12 December 2008 at 3:36pm
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 -
Re: Adding a new page below another page

12 December 2008 at 4:02pm
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();
}
| 947 Views | ||
|
Page:
1
|
Go to Top |

