php - SilverStripe ModelAdmin -
i new silverstripe framework , trying fetch list of menu in admin panel.
i found lots of example show menu on front-end menu(1) , menu(2) etc. did not sample code fetch same menu array in admin model.
the code tried is:
public function getcmsfields() { $fields = fieldlist::create(tabset::create('root')); $fields->addfieldstotab('root.main', array( textfield::create('name'), dropdownfield::create('url') ->setsource(sitetree::get()), )); return $fields; }
modeladmin there manage dataobjects , not pages. have @ docs , lesson learn more modeladmin.
but if want manage pages in modeladmin, that
class mypageadmin extends modeladmin { ... ... private static $managed_models = array( 'page' ); public function getlist() { $list = parent::getlist(); if($this->modelclass == 'page'){ $list = $list->filter('parentid', '1'); } return $list; } }
to manage children specific page, use getlist() function , filter list after needs.
Comments
Post a Comment