Components

Components are the building blocks of any IQcms project. They are responsible for the Routing, Controller, Model and view layers of the application.

A component always has the following properties:

  • _component_id: This is the id assigned to this component by the system

  • _url: The url configured for this component

  • _pid: The id of the current profile

  • _type: The textual representation of the type of the component type

  • _short_url: The shortened url E.G “short12”

  • _container: The textual representation of the container this component is in, defaults to null when not inside of a container

  • _published: A boolean flag representing whether or not this component is published

  • _position: A number indicating the componets position relative to its sibling, useful for sorting

  • _parent_id: The component_id of the parent component, defaults to null if none is found

  • _title: The textual title of this component, this is also used to generate a _url for this component upon saving

  • _sitemap_crawlrate: Textual representation of how often this components page should be crawled by search engines, possible values are "never", "always", "hourly", "monthly", "daily", "weekly", "yearly"

  • _sitemap_priority: The priority of this components page, this is a float value ranging from 0 to 1

  • _symbol: A unique textual value that can be c t state of the component. TBD

Component types

Component types are a way to identify components, it is used internally to match a components data from the database to the correct class.

The following conventions apply to a component type:

  • A component type is always persisted without any casing (all lowercase).

  • The namespace (and by extension the folder name) that will be used for finding the component code will be iq\components\{{component type}} where {{component type}} is the all lowercase value of the component type

  • The classname that will be used for this component type will be all lowercase, but with only the first character capitalized

For example, if the component_type is "prettyexamplepage" the following class will be used for this component iq\prettyexamplepage\Prettyexamplepage

As long as these conventions are followed. the component types should fill and regulate themselves. And there should be almost no need to manipulate their values directly

Containers

Containers are a way to add child components to a component that should not be accessible as pages.

Adding a container to a component

You can add a container to a component by adding it to the configuration file for a component:

// /components/example/config.php

$containers = &$config['tabs'][PID_TAB]['sections']['default']['containers'];

$containers['example'] = [
    'label' => 'Example',
    'allowed_components' => [
        'othercomponent'
    ]
]

When configuring a container you have the following options:

Option

Definition

label

The label used for this container in the cms.

allowed_components

The component type that are allowed in this container

Read more on config.php

Routing into a component

When a request comes into the application It is passed onto a component. The component responsible for handling the request is determined based on its slug property.

Querying other components

From within a component it is possible to query other components. There are a few ways to accomplish this.

  • The ComponentFactory singleton