Apache Sling > Sling CMS > Developers > Custom Components
Components in Sling CMS are used to render data stored in the Sling Repository to users. Each component is denoted by the jcr:primaryType
of sling:Component
.
Components are expected to have the following structure:
/component jcr:primaryType=sling:Component jcr:title=My Component componentType=[Component_Type] /edit jcr:primaryType=nt:unstructured sling:resourceType=sling-cms/components/editor/slingform [...] /config jcr:primaryType=nt:unstructured sling:resourceType=sling-cms/components/editor/slingform [...] /component.jsp jcr:primaryType=nt:file
The componentType
attribute defines the component type groups the component belongs to. This is used to group the components when adding a new component and to control what components can be added within a container.
A component can belong to one or more groups. If a component belongs to no groups it will not be addable to any containers.
The editor is defined by the edit sub-node and is required for a component to be addable to a container.
This node structure will be used to define the form for editing an instance of the component. This node should have the resource type sling-cms/components/editor/slingform
and should have a button attribute.
See the editor field types for a list of the default field types.
The config is defined by the config sub-node and is not required.
This node structure will be used to define the form for editing a shared configuration for that component for every page instance using the same template. This node should have the resource type sling-cms/components/editor/slingform
and should have a button attribute.
This config form can be accessed when adding a component configuration for this component to a template.
See the editor field types for a list of the default field types.
Any number of scripts can be used to render the component to user. See Sling Resource Resolution for more details on how the scripts are resolved. Sling CMS supports JSP, HTL and ECMAScript.