English plugin dev 4 4 - movabletype/Documentation GitHub Wiki
In the previous chapter we explain how to mass up^H^H modify a management screen
Now we will show how to add a shiny new management screen to the CMS
On the left of the CMS screen, there are the main menus. Their context can very depends on where you are and can be either system-level, website-level and blog-level. You can choose which of the levels should include your screen.
In addition, there is a small drop-down menu on the upper-right corner. It is mainly used to create new things (such as a blog or an entry) and there too you can add your command.
All these, rather then be changed by a transformer plugins, are controlled through the registry, and menu entries can be add simply by specifying them in your plugins’ config.yaml
- Hide the “Tools” menu for non-administrators
- Let’s suppose to a minute that these non-admins have no need for the search & replace option…
- ウェブサイトメニューからブログ記事メニューを見せなくする
- ウェブサイトに直接ブログ記事を表示させたくない場合を想定
- Create a top-level menu called “New Menu”, and inside a menu item “dashboard”
- Should be available in all contexts: system, website, blog, user
- When a user click on the dashboard menu, he should be forwarded to the dashboard
id: MyPlugin14 key: MyPlugin14 name: <__trans phrase="Sample Plugin Menu Customize"> version: 1.1 description: <__trans phrase="_PLUGIN_DESCRIPTION"> author_name: <__trans phrase="_PLUGIN_AUTHOR"> author_link: http://www.example.com/about/ doc_link: http://www.example.com/docs/ l10n_class: MyPlugin14::L10N applications: cms: menus: tools: permission: administer system_permission: administer entry: view: blog new_menu: label: New Menu order: 1000 new_menu:dashboard: label: Dashboard order: 100 view: - system - website - blog - user mode: dashboard condition: sub { return 1 }
id: MyPlugin14 key: MyPlugin14 name: <__trans phrase="Sample Plugin Menu Customize"> version: 1.0 description: <__trans phrase="_PLUGIN_DESCRIPTION"> author_name: <__trans phrase="_PLUGIN_AUTHOR"> author_link: http://www.example.com/about/ doc_link: http://www.example.com/docs/ l10n_class: MyPlugin14::L10N
- this section defines the plugin’s… um, you probably know this section by now. let’s go on.
applications: cms: menus:
- This is the hierarchical place of the menus in the registry
tools: permission: administer system_permission: administer
-
tools
– referring to the tools menu -
permission
– set required permission for website and blog context -
system_permission
– set required permission for system-level context - If there are several permission required, you can specify them separated with comma
- Now the
tools
menu will be displayed only to the administrator
entry: view: blog
- この設定により
entry
「ブログ記事」のview
をblog
だけで表示します- このためサイトメニューから「ブログ記事」メニューが消えます
new_menu: label: New Menu order: 1000
- Add another menu
- The label will be automatically localized. (if available) so “New Menu” will be converted to “新規メニュー” for Japanese users
-
order
– we want to put it below the “tools” menu, and the order of the tools menu is 900, so we selected 1000- The menus are sorted by
order
, with the smallest value first
- The menus are sorted by
new_menu:dashboard: label: Dashboard order: 100 view: - system - website - blog - user mode: dashboard condition: sub { return 1 }
- Add a “Dashboard” menu-item under the “New Menu” menu
- If this screen should appear in more then one context,
view
should be an array of all the allowed contexts-
system
for system-overview,website
andblog
for when looking on a website or a blog, anduser
for the user dashboard
-
- When this menu item will be clicked, the user will be forwarded to the specified mode, in this case
dashboard
-
condition
allow you to make arbitrary assertions on when this menu item will appear.- returning 1 is equal to saying “always”, and also equal to not specifying condition at all
- return false to tell MT not to display it
- You can also put a handler in the form of
condition: $MyPlugin14::MyPlugin14::Menues::hndr_get_condition
You can also specify:
args: _type: foo
- Giving additional arguments to the mode
- The resulted URL will be:
http://www.example.com/cgi-bin/mt.cgi?__mode=dashboard&_type=foo&blog_id=1
- The resulted URL will be:
dialog: 1
- Instruct MT to open the URL in a modal window, instead of forwarding to whole screen
$MT_DIR/ |__ plugins/ |__ MyPlugin14/ |__ config.yaml |__ lib/ |_ MyPlugin14/ |__ L10N.pm |_ L10N/ |_ en_us.pm |_ ja.pm
Prev:Developing a transformer plug-in << Index >> Next:Add an action list