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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -