Merge two page type in SilverStripe -
$page1 = pagetype1::get(); $page2 = pagetype2::get();
is there way in fetch latest 5 post combination of 2 page type. accepted.
assuming pagetype1
, pagetype2
both children of page
class can do:
$mypages = page::get()->filter(['classname' => ['pagetype1', 'pagetype2']]);
or other parent class of both page types.
you can sort date created (which saved in sitetree table), , limit, e.g.
$sortedandlimited = $mypages->sort('created')->limit(5);
downside: cannot search, filter or sort individual fields not shared parent class page
, doing need make joins manually.
Comments
Post a Comment