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

Pages generating


Reply


2 Posts   1118 Views

Avatar
nSwCZ

Community Member, 2 Posts

12 February 2009 at 1:12pm

I need to automatically generate the SiteTree (Page) node (after the user registration) but the following code add an empty node in the Menu (Site) Tree and cause an error while deleting in the CMS editor.

<code>

class SubjectPage extends Page { ... }

class RegistrationFormPage_Controller extends Page_Controller {
...

function SignUpAction($data, $form) {
...
         $subject2 = DataObject::get_by_id("SubjectPage", 19);
         $subject = $subject2->duplicate(true);
         $subject->setParent(13);
         $subject->Title = $data['Nick'];
         $subject->setMenuTitle($data['Nick']);
$subject->write();
...
}
}
</code>

What's wrong?

Avatar
nSwCZ

Community Member, 2 Posts

13 February 2009 at 1:25am

the same with a holder page (posted http://www.silverstripe.org/archive/show/248511)
class SubjectHolderPage extends Page { }

<code>
         $subject_holders = DataObject::get('SubjectHolderPage');
         $subject_holder_first = $subject_holders->First();
         $subject = new SubjectPage();
         $subject->Title = $data['Nick'];
         $subject->setMenuTitle($data['Nick']);
         $subject->URLSegment = $data['Nick'];
         $subject->setParent($subject_holder_first);
         $subject->write();
</code>

create an empty node in the site tree :-(