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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -