MidCOM Components

From MidgardWiki

Revision as of 11:00, 6 February 2009 by WikiSysop (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

MidCOM Components are reusable applications which provide a set of defined functionalities to a Topic on a MidCOM-based Host. There are components for many common web tasks, like blogs, forums, photo galleries and also complex applications like OpenPSA. See a List of MidCOM Components for details.

Besides the regular Components, which send output to the browser, there is also a number of so-called Purecode Components, which provide functionality that can be included in other Components and Elements.

Contents

Component Installation

Starting with MidCOM 2.6, Components are available as PEAR packages and can be installed using the pear command-line tool. A number of Components is installed by Datagard during installation. They provide basic features like the adminstration interface (Asgard 2) and tools for site management.

Customizing

With MidCOM Datamanager and Datamanager Schemas, content structure and output can be customized. Furthermore, you can modify the default Style Elements and use MidCOM Component Configuration settings to influence the Component's behaviour.

Getting hold of a Component's data

MidCOM Components store data relevant to the current request in a global array which is automatically available within the component context in the variable $data. Before MidCOM 2.8, the compoent's data could be accessd with the method get_custom_context_data

Working with Style Elements

The above data is also available to Style Elements, if the system is in the Content Output Phase (see also: Midgard Execution Phases) and can thus be used to produce or modify the Component Output. Style Elements can be called during the Content Output Phase from the Style elements style-init and style-finish. Each non-Purecode Component comes with a number of default Style Elements that can be overwritten. See Templating in MidCOM for details.

MidCOM can also load Style Elements with the function midcom_show_style from the Style or Substyle associated with the Topic (see also: Midgard Execution Phases).

Configuration

Components come with a default configuration, which can be overwritten for the entire Sitegroup in the Snippetdir sitegroup-config where the contents of the Component's config directory can be overwritten by creating a new Snippet named like the Component's config file and editing it.

Configuration options can also be altered for individual Topics by creating Parameters where domain holds the name of the MidCOM Component, name the name of the config option and value the new value. Usually, the Parameter creation happens automatically when using the configuration handlers provided in the MidCOM Toolbars, so site admins don't have to worry about the specific database operations.

The data structures of most Components can be altered with Datamanager Schemas. A custom Schema can be defined for the entire Sitegroup or for one Topic

Development

Components are able to access the functionality of the Midgard and MidCOM Frameworks through inheritance of the MidCOM Component Base Classes. Usually, they are linked to Topics and make their functionality (class methods and data output) available to all objects called during the Content Output Phase (see also MidCOM Execution Phases) which consist mostly of Style Elements, included Snippets and PHP-enabled Articles).

You can also load both Purecode and regular Components from within other Components with midcom_helper_componentloader, available in the MidCOM PHP Superglobal:

//regular components:
$_MIDCOM->componentloader->load('net.nehmer.static');
//purecode components:
$_MIDCOM->load_library('midcom.admin.folder');

Structure of a MidCOM Component

Each Component contains the following directories:

  • config contains the default Datamanager Schemas and the MidCOM Component Manifest and a config file
  • documentation
  • handler contains the handler classes
  • locale contains files with the defined localization strings
  • midcom contains the interface definition
  • style contains the Component's default Style Elements

optional directories:

  • callbacks for callback functions (e.g. form validation callbacks)
  • cron' for scripts called from cron
  • exec for scripts called with the MidCOM URL Method midcom-exec-
  • static contains static files which are copied to midcom-static during installation

Namespacing

Each Component has a unique name, which is constructed similar to names a Java packages and consists of the web address of the organization or person who wrote the Component and an identifer. For example: de.linkm.newsticker is the newsticker Component written by an organization with the web address linkm.de.

The Component's name also serves as a prefix to the Component's classes, for example net.nehmer.branchenbuch classes are called net_nehmer_branchenbuch_entry, net_nehmer_branchenbuch_admin and so on.

Personal tools