Jump to:

23358 Posts in 17875 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Pages generating

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: 1050 Views
  • nSwCZ
    Avatar
    Community Member
    2 Posts

    Pages generating Link to this post

    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?

  • nSwCZ
    Avatar
    Community Member
    2 Posts

    Re: Pages generating Link to this post

    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

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