Jump to:

23007 Posts in 11866 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Overloading requireDefaultRecords for Home

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: 366 Views
  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Overloading requireDefaultRecords for Home Link to this post

    Is there anyway to change the PageType for Home in the requireDefaultRecords() to differnt page type other than Page without editing the core file?

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Overloading requireDefaultRecords for Home Link to this post

    Sure, requireDefaultRecords is run once per class so on your Page.php

    function requireDefaultRecords() {
    parent::requireDefaultRecords();

    $home = DataObject::get_one("Page", "URLSegment = 'home'");
    $home->ClassName = "NewSomethingClass";
    $home->write();
    $home->publish('Stage', 'Live');
    }

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