Open Source Content Management System

MidCOM component toolbars

  1. Using toolbars in components
  2. Displaying the toolbars
  3. Why use these toolbars?

MidCOM provides a standard interface for component toolbars. If a component wants to expose some actions in site menu the toolbars should be used.

Using toolbars in components

The toolbars service provides three static midcom_helper_toolbar instances that you can populate by adding buttons:

  • view: Toolbar items affecting current page
  • node: Toolbar items affecting current node (including creation of new pages under the node
  • host: Toolbar items affecting the whole website

The view and node toolbars are populated automatically to handler classes as $this->_node_toolbar() and $this->_view_toolbar().

Buttons are added in the following way:

$this->_view_toolbar->add_item
(
    array
    (
      // Normal toolbar item array
    )
);

Displaying the toolbars

If you wish to use the centralized MidCOM toolbar in your layout, include the following in the beginning of the HTML body element:

<?php
$_MIDCOM->toolbars->show();
?>

If you wish to instead display the node and view toolbars separately, you can use the following methods:

<?php
$_MIDCOM->toolbars->show_node_toolbar();
$_MIDCOM->toolbars->show_view_toolbar();
?>

If the centralized toolbar is in use on the site, these two methods will produce no output.

Why use these toolbars?

If all components use the toolbars in consistent ways, it is much easier for layout template writers to place and style the toolbars in consistent and fitting manner.

It also means that all components will have more or less consistent UI.

When using the toolbars please also observe the Access Key guidelines.

Designed by Nemein, hosted by Anykey