Adding Menu Items
Movable Type allows you to add menu items to the main navigation of the site. This is a great way for you to provide convenient links to your users and an intuitive way in which to access your plugin.
The following sample code will add a menu item labeled "Upload Video" to the Create menu.
sub init_registry {
my $plugin = shift;
$plugin->registry({
applications => {
cms => {
menus => {
'create:video' => {
label => 'Upload Video',
mode => 'video_upload',
order => 301,
args => { _type => "blog" },
permission => 'manage_assets,publish_post',
view => "blog",
},
},
},
},
});
}
Here is an overview of the various properties of a menu item:
- label - the name of the menu item as it will appear in the menu
- mode - the app mode that will be invoked when you click the link. Note: this will require you to define and register an app mode with the same name as the value of this property.
- dialog - as an alternative to
modeone can specifydialogwhich will spawn a dialog window that invokes the mode with the name assigned to thedialogproperty - order - the order or placement as it will appear in the list.
- permission - a comma delimited list of required permissions in order for this menu item to be active for the current user
- args - a list of key/value pairs of querystring parameters that will be appended to the link associated with this menu item
- view - valid values are "blog" or "system" and they determine whether the menu item should appear in the blog context menu set or the "System Overview" menu set.
List of Permissions
The following permissions are defined by Movable Type by default and can be used in conjunction with the "permission" property defined above:
System Permissions
- administer
- create_blog
- manage_plugins
- view_log
Blog Level Permissions
- administer_blog
- edit_config
- set_publish_paths
- edit_categories
- edit_tags
- edit_notifications
- view_blog_log
- create_post
- publish_post
- send_notifications
- edit_all_posts
- manage_pages
- rebuild
- edit_templates
- upload
- save_image_defaults
- edit_assets
- comment
- manage_feedback
5 User Contributed Notes
I have discovered that in order for menu items to appear properly the plugin you register with Movable Type must extend the MT::Plugin class. For example:
package MT::Plugin::MyPlugin; use MT; use strict; use base qw( MT::Plugin ); my $plugin = MT::Plugin::MyPlugin->new({ name => 'MyPlugin', }); MT->add_plugin($plugin);For System Permissions, "administrator" is not a valid option; try "administer" instead.
@Dan Wolfgang: thanks for pointing that out. Today I stumbled across the same bug, and just fixed it. Apologies for not fixing it before.
Is it possible to create a new top-level menu, or do all new menu items need to go under an existing top-level (like "create" in the example)?
Absolutely!
sub init_registry { my $plugin = shift; $plugin->registry({ applications => { cms => { menus => { 'mymenu' => { label => "My Top Level Menu", order => 500, }, 'mymenu:item' => { label => 'My Menu Item', mode => 'foo', order => 100, args => { _type => "blog" }, view => "blog", }, }, }, }, }); }