Merging two types of pages in SilverStripe
1 answer
Assuming PageType1
u PageType2
are children of the class Page
you can do:
$myPages = Page::get()->filter(['ClassName' => ['PageType1', 'PageType2']]);
or any other parent class of both types of pages.
You can sort by the date created (which is saved in the SiteTree table) and limit eg.
$sortedAndLimited = $myPages->sort('Created')->limit(5);
Downside: You cannot easily search, filter or sort for individual fields that are not used by the parent class Page
, you have to do the joins manually for that.
+4
source to share