Creating pages
To create a CMS page for an entity defined in your database schema, create an admin.xml file alongside your schema.xml file.
Sections
Sections are the top level groups of your CMS navigation. They don't provide any specific functionality, but improve end-user experience by creating clear visual classifications of your CMS content. Every page that you would like to make available in the CMS navigation needs to be assigned to a section.
<section name="blog" icon="news">
<title>Blog</title>
</section>
| Attribute | Type | |
|---|---|---|
| name | string (required) | Uniquely identifying name for the section. |
| icon | string | Icon name. Supported values are dashboard, news, pages, image, video, briefcase, mail, house, location, cog, buildings, money, car, person, globe, tag, screen, printer and calendar. |
| index | integer | Numerical order of the section, relative to other sections. Defaults to 50. |
Pages
Once you've defined a section, you can create your first page. To do so, add a page tag and assign it to your section. Then add a title and content tag to provide its name and content respectively.
<page section="blog">
<title>Blog</title>
<content>
<p>This is an example page</p>
</content>
</page>
| Attribute | Type | |
|---|---|---|
| section | string | Name of the section under which the page should appear in the navigation. |
| for | string | Name of the database schema entity for which this page should provide functionality. |
| index | integer | Numerical order of the page in the navigation, relative to other pages. Defaults to 50. |
Making static entities editable
To provide editing functionality for a static entity defined in your database schema, set its name as the for attribute of your page. Then add input tags for each of the field that you wish to allow the user to edit (set the for attribute to the field name). Each of these input tags should preferably also have a title tag to describe the field.
<static name="blog">
<string name="title"/>
</static>
<page section="blog" for="blog">
<title>Blog</title>
<content>
<input for="title">
<title>Blog title</title>
</input>
</content>
</page>
Making non-static entities editable
To allow the user to create/update/delete non-static entities, we first need to display a list of records for this entity. To do so, add a list tag to a new or existing page and set its for attribute to the name of the entity. Then add column tags for the fields that you want to display in the list. These column tags should also contain title tags to describe the fields.
<entity name="blogitem">
<string name="title"/>
<text name="content"/>
</entity>
<page section="blog">
<title>Blog</title>
<content>
<list for="blogitem">
<column for="title">
<title>Title</title>
</column>
</list>
</content>
</page>
We can then proceed to making these items editable by creating a second page and setting its for attribute to the same entity name. For this page it's recommended to add singular and plural tags to its title.
<page section="blog">
<title>Blog</title>
<content>
<list for="blogitem">
<column for="title">
<title>Title</title>
</column>
</list>
</content>
</page>
<page for="blogitem">
<title>
<singular>Item</singular>
<plural>Items</plural>
</title>
<content>
<input for="title">
<title>Item title</title>
</input>
<input for="content">
<title>Item content</title>
</input>
</content>
</page>
Lists can implicitly infer a field's title from a relevant page's inputs. This allows us to omit explicit titles once an input is provided.
<page section="blog">
<title>Blog</title>
<content>
<list for="blogitem">
<column for="title"/>
</list>
</content>
</page>
Displaying non-editable entity content
If you would like to show entity data without editing capabilities, use a value tag instead of an input tag.
<page for="comment">
<title>
<singular>Comment</singular>
<plural>Comments</plural>
</title>
<content>
<value for="content">
<title>Can't edit this</title>
</value>
</content>
</page>
Internationalisation
Tags like title, p or h2 can be translated by duplicating them and setting language attributes.
<page section="news">
<title language="en">News</title>
<title language="nl">Nieuws</title>
<title language="fr">Nouvelles</title>
<content>
<list for="newsitem">
<column for="title">
<title language="en">Title</title>
<title language="nl">Titel</title>
<title language="fr">Titre</title>
</column>
</list>
</content>
</page>