Silverstripe 4.6 ModelAdmin dynamic $menu_Title

45 views Asked by At

Is it possible to dynamically change the ModelAdmins $menu_Title to e.g.

Member::currentUser()->Name ?

How ? Thanks.

1

There are 1 answers

0
Sepp Hofer On BEST ANSWER

Ok. I got it.

<?php

use SilverStripe\Admin\ModelAdmin;
//...
//...

class UserAdmin extends ModelAdmin
{ 
    
     private static $managed_models = array(
        'YourDataObject'
    );
    
    private static $url_segment = 'test';
    private  static $menu_title = 'Test';
    private static $menu_icon_class = 'fa fa-pagelines';

    
    public function getEditForm($id = null, $fields = null)
    {
        $form = parent::getEditForm($id, $fields);
        //.......
        //.......
        return $form;
    }
    
    
     public static function menu_title($class = null, $localise = true){
         //return 'YOUR MENU TITLE';
         return Member::currentUser()->Name; 
     }
    
}