Creating Menu Items
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",
condition =>
sub {
my $code_returning_1_or_zero = 1;
// alternatively could be a call to a subroutine defined elsewhere
return $code_returning_1_or_zero;
},
},
},
},
},
});
}
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 that would allow this menu or menu item to be active for the current user.
- args - a list of key/value pairs of query string 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.
- condition - subroutine or handler that should return 1 (true) or zero (false) to indicate whether or not the menu item will appear in a given context. (You can use MT->instance to get and perform tests on a wide variety of contextual information.)
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
Byrne Reese on August 5, 2007, 6:07 p.m. 返信
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:
Bryant on February 29, 2008, 11:59 a.m. 返信
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)?
Byrne Reese on February 29, 2008, 12:07 p.m. 返信
Absolutely!