Jump to:

23360 Posts in 18124 Topics by 2862 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: 409 Views
  • zenmonkey
    Avatar
    Community Member
    527 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
    5483 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');
    }

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