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 tonull
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
: Thecomponent_id
of the parent component, defaults tonull
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 from0
to1
_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 typeThe 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 |
---|---|
|
The label used for this container in the cms. |
|
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