Bitrix Site Manager

Compound components

Definitions

Simple (single page) components create an area in a given single page. For example, the news display component creates a news display area in which it renders the news title and body, in a page where it is placed.

Compound (multiple page) components create site sections. For example, the catalog component creates the whole catalog section: catalog entries, catalog groups, product pages. In other words, a compound component form a set of pages. Compound components are built on the basis of simple components.

MVC

The foundation of compound components is the MVC (Model View Controller) design pattern. This concept breaks application data model, user interface and logic into three separate, individual parts in such a way that any change in one of the areas makes a minimum impact on others.

A typical flow of the MVC pattern is as follows.

When applied to compound components, the MVC algorithm works in the following way.

Example

Consider a simple example of how a news compound component may function. Say we have the following simple components: "list of news" and "news details", the latter takes the ID of news to be displayed as input parameter.

The news site section can be created, for example, by adding the "list of news" component to a section index page, and creating a news.php page and adding the "news details" component to it. The components must be properly configured: the list of news is to be able to build links to a news details page including the news ID; the news details component should have input parameters configured in such a way that it would be able to display a link to the list of news.

Configuring the components properly requires that we know the path to the news details page, the name of all parameters that the components can take on input, etc. Even in this example, configuring may be a headache. But imagine tenths of forum components!

An easier alternative that a web developer can take is using the news compound component. You can simply add this component to the index page. The component will take full control over maintaining correct links and parameters; this will not require any additional actions on the developer side. Creating the news complex component requires that you check the news ID in URL's. If an URL contains the news ID, the component will activate the page that would display the news text. Otherwise, the component would display the list of news.

Pages of the compound component template would connect simple components and configure their input parameters properly. Simple components will carry out their functions as usual; the only important thing is configuring the input parameters correctly.

Thus, the MVC pattern flow works as follows: