Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Change menu_title of ModelAdmin

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 832 Views
  • swaiba
    Forum Moderator
    1792 Posts

    Change menu_title of ModelAdmin Link to this post


    I have a ModelAdmin where I need to change the name that appears in CMSMenu, but I cannot just change the...

    static $menu_title = 'MyAdminOldName';

    ...I NEED to find a way of doing it outside of just changing the original static declaration.

    I have tried and failed with...

    inside a custom leftandmain decorator (does nothing)...

    $menu_item = CMSMenu::get_menu_item('MyModelAdmin');//does return the right CMSMenuItem

    inside the init function of the extended ModelAdmin (does nothing)...

    public function init()

    in _config.php (complains about trying to use a database object before the database has been initialised)...


    Any ideas?

  • martimiz
    Forum Moderator
    1086 Posts

    Re: Change menu_title of ModelAdmin Link to this post

    Adding a translation to your languagefile will do the trick. Suppose your ModelAdmin class is called MyModelAdmin:

    In cms/lang/en_US.php add:

    $lang['en_US']['MyModelAdmin']['MENUTITLE'] = 'Some Menutitle';


  • swaiba
    Forum Moderator
    1792 Posts

    Re: Change menu_title of ModelAdmin Link to this post

    Now why didn't I think out that... Doh!

    Many thanks Martimiz

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.