Cyclone3 Skin

Servicetype layer

From Cyclone3 Wiki

(Redirected from Layer)
  • Extension: *.cml_gen (see Naming conventions)
  • Extension: _type directory
  • Caching: not cached

A layer helps you separate and organize modules, which are used in more than one TypeID. This way, you don't need to change all TypeID files when you need to change a parameter in one of the modules which are the same for them, you will only need to make a single change, and it will be applied everywhere, where this layer is included.

Let's see an example. We have two different TypeID files - one for displaying an article list,

<CONF_KEY name="a401_article_cat.ID" description="Article category ID" select="a401_article_cat.ID" public="1" />

#the default page layout
<CONF_VAR id="body" value="layout" />

#header
<MODULE>
...
</MODULE>

#menu
<MODULE>
...
</MODULE>

#article list
<MODULE>
...
</MODULE>

#footer
<MODULE>
...
</MODULE>

and one displaying an actual article

<CONF_KEY name="a401_article.ID" description="Article ID" select="a401_article.ID" public="1" />

#the default page layout
<CONF_VAR id="body" value="layout" />

#header
<MODULE>
...
</MODULE>

#menu
<MODULE>
...
</MODULE>

#article view
<MODULE>
...
</MODULE>

#footer
<MODULE>
...
</MODULE>

As you can see, there are similarities - we are loading the same page layout, and the same header, menu and footer definitions. Imagine you had 10 TypeID files and you needed to change an attribute for the menu module. That'd be 10 times opening, editing and saving a file. Let's make it easier, take the identical parts, and put them together into a layer file, named default:

#the default page layout
<CONF_VAR id="body" value="layout" />

#header
<MODULE>
...
</MODULE>

#menu
<MODULE>
...
</MODULE>

#footer
<MODULE>
...
</MODULE>

and now, we can replace the definitions in both TypeID files with a single line, now, they will look like this:

<CONF_KEY name="a401_article_cat.ID" description="Article category ID" select="a401_article_cat.ID" public="1" />

#the default layer with default modules
<CONF_VAR id="layers" value="default" />

#article view
<MODULE>
...
</MODULE>

and

<CONF_KEY name="a401_article.ID" description="Article ID" select="a401_article.ID" public="1" />

#the default layer with default modules
<CONF_VAR id="layers" value="default" />

#article view
<MODULE>
...
</MODULE>

That's it! Now, if you need to change anything in the separated modules' definitions, you just open the layer file and change it there, to be reflected in all service type files which are including it.