Skip to content
flack edited this page Sep 26, 2019 · 24 revisions

MidCOM Components are reusable modules which provide a set of defined functionalities. There are components for many common web tasks, like blogs, wikis, slideshows and also complex applications like OpenPSA, which combine multiple components.

Besides the regular components, which are bound to a Topic, there is also a number of so-called Purecode Components, which provide functionality that can be included in other code (like the commenting system), or that is accessible via the browser (like the on-site administration tools).

Structure

These are the folders/files you will typically encounter in components:

path description
config/ contains the Component Manifest, a config file, the Routing information, and optionally the default Datamanager Schemas
cron/ holds the component's cron jobs, if any
documentation/ contains the component's documentation
exec/ for scripts called with the MidCOM URL Method midcom-exec-
handler/ contains the request handler classes
locale/ contains files with the defined localization strings
midcom/ contains the component interface class
style/ contains the Component's default Style Elements
navigation.php integration into the Navigation service
viewer.php integration into the Routing system

All components have to provide config/manifest.inc and midcom/interfaces.php (which extends midcom_baseclasses_components_interface) so that the framework is able to work with them.

Non-Purecode components additionally have to provide navigation.php (which extends midcom_baseclasses_components_navigation) and viewer.php (which implements midcom_baseclasses_components_request).

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 identifier. 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_navigation and so on.

Component Installation

Starting with OpenPSA 9, components can be installed via Composer. A number of Components is bundled in the main repository. They provide basic features like the adminstration interface (Asgard) and tools for site management.

Customizing

You can modify the default Style Elements and use Component Configuration settings to influence the Component's behaviour. The builtin l10n strings can also be overridden

Working with Style Elements

MidCOM Components store data relevant to the current request within the component context in the variable $data, which is also available to Style Elements, 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](style-init) and [/style-finish](style-finish). Each non-Purecode Component comes with a number of default Style Elements that can be overwritten. See Style Engine for details.

MidCOM can also load Style Elements with the function midcom_show_style from the Style or Substyle associated with the Topic.

Development

Components usually provide their functionality through handlers (which correspond to controllers in Symfony e.g) which react to certain URLs registered in the Routing system. They are able to access the functionality of the MidCOM framework through inheritance of the Component Baseclasses. Usually, they are linked to Topics and make their functionality (class methods and data output) available, which consist mostly of Style Elements, included Snippets and content.

You can also load both Purecode and regular components from within other components with midcom_helper_componentloader, available in the midcom accessor:

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