My first content app Part II
Creating a basic content app
This page is the second part of the My first content app tutorial and describes how to configure and create a basic Bookshelf, a Magnolia content app.
The configuration is done using Magnolia content types – formal definitions for types of content in Magnolia including the properties the type may contain and its relationships to other types of content.
Prerequisites
For development and testing, you need a running instance of Magnolia.
In this tutorial, we suppose that it’s installed in a directory called magnolia.
| If you don’t have Magnolia installed and running, go to Installing Magnolia and complete the installation steps. Then, return and proceed from here. |
Creating the bookshelf light module
Magnolia light modules usually define page, area and component templates and many more things.
In this tutorial, we use a light module called bookshelf to create a content app.
The module contains both a definition of content types and the app descriptor.
-
Navigate to:
-
The
light-modulesfolder of your Magnolia installation, if you installed your Magnolia via Magnolia CLI. -
To the
../webapps/magnoliaAuthor/modulesfolder, if you unpacked and started your Magnolia from a donwloadable bundle.In this case, make sure that whatever light module code changes described below you introduce to this folder, you also apply to the ../webapps/magnoliaAuthor/modulesfolder.
-
-
Create a new folder named
bookshelf. -
Inside the
bookshelffolder, create the following folder structure:Skip this step if you installed your Magnolia via Magnolia CLI. bookshelf ├── apps ├── contentTypes └── i18n
Creating the app configuration files
In the bookshelf light module, you need to create two configuration files:
-
An app descriptor in the
appsfolder -
A content type definition in the
contentTypesfolder
Creating the content type definition
-
In the
contentTypesfolder, create a file namedbook.yaml. -
Save it with the following content:
book.yaml (content type definition)datasource: (1) $type: jcrContentTypeDatasource workspace: books namespaces: lib: https://www.magnolia-travel.com/jcr/1.0/lib autoCreate: true model: (2) nodeType: lib:book properties: (3) - name: authors - name: ed (4) type: Boolean - name: title - name: description - name: publisher - name: publish_date (5) type: Date - name: isbn131 Defines how the content type items are persisted. For more details see the Content type Data source definition page. 1 Defines the node type and the properties of the new content item for the Bookshelf app. 2 Defines the app properties. Defaults to the Stringtype if no other type is supplied.1 Set the type of the edproperty toBooleansince it is more appropriate in regard to the values the system can store (true,false).2 Set the data type of the publish_dateproperty toDateso that the value would be stored in the JCR as calendar object.
|
The content type definition creates a new workspace called |
Creating the app descriptor
-
In the
appsfolder, create a file namedbookshelf-app.yaml. -
Save it with the following content:
bookshelf-app.yaml (app descriptor)!content-type:book (1) name: bookshelf-app (2)1 The app descriptor instructs the app generator to construct the app from the bookcontent type definition.2 You give the app the name bookshelf-app, under which the app is known to other resources and systems in Magnolia.
The final folder structure of your bookshelf light module should look like this:
bookshelf
├── apps
│ └── bookshelf-app.yaml
├── contentTypes
│ └── book.yaml
└── i18n
Check the app in the Definitions app
After saving the changes, start or restart your Magnolia instance.
Then, go to the Definitions app on the author instance to check that the app’s definitions have been loaded by Magnolia (the bookshelf-app should appear in the apps folder).
In case the bookshelf-app isn’t there or there’s a problem notification next to it, please double-check that all your yaml files have been copied exactly as they appear in this tutorial.
Starting the app
Magnolia adds a tile for your new app to the App launcher automatically when registering the app.

|
i18n message keys and the Name, Title and Description labels The
In the last part of the tutorial, you create new label values in subsection Adding an i18n message bundle. |
