Beruflich Dokumente
Kultur Dokumente
27.07.2010
Version: 1.0
Table of contents
Introduction to Magnolia CMS architecture............................................................................................ 6
AdminCentral............................................................................................................................................. 7
Authoring ................................................................................................................................................... 9
Instances ................................................................................................................................................. 12
Public instances serving different content ............................................................................................. 13
Intranet and extranet ............................................................................................................................. 14
Planned redundancy and high availability ............................................................................................. 14
Instance configuration examples ........................................................................................................... 15
Content delivery ...................................................................................................................................... 16
Subscribers............................................................................................................................................ 16
Content storage and structure............................................................................................................... 17
Repository ............................................................................................................................................. 17
Workspaces........................................................................................................................................... 17
Magnolia CMS workspaces ............................................................................................................... 19
Hierarchical content store...................................................................................................................... 20
JCR standard API for content repositories ............................................................................................ 21
Persistent storage ................................................................................................................................. 22
Clustering ................................................................................................................................................ 24
Jackrabbit clustering.............................................................................................................................. 24
Modules.................................................................................................................................................... 26
Pluggable and independent................................................................................................................... 26
Configuration ......................................................................................................................................... 27
JAR structure......................................................................................................................................... 28
Module class ......................................................................................................................................... 29
Dependencies ....................................................................................................................................... 29
Module life-cycle.................................................................................................................................... 30
Bootstrap files........................................................................................................................................ 30
Version handling.................................................................................................................................... 31
Community driven module development ............................................................................................... 32
Magnolia webapp .................................................................................................................................... 33
Directory structure ................................................................................................................................. 33
Adding the Magnolia main filter to the webapp ..................................................................................... 34
Adding the Magnolia context listener .................................................................................................... 35
Request processing and filters.............................................................................................................. 36
Magnolia CMS filter chain ..................................................................................................................... 36
Templating ............................................................................................................................................... 39
Pages and paragraphs .......................................................................................................................... 39
Templating mechanism ......................................................................................................................... 40
Component relations ............................................................................................................................. 41
Templating languages ........................................................................................................................... 42
Tag library.............................................................................................................................................. 43
Example of CMS tags in use ................................................................................................................. 45
Templating support objects ................................................................................................................... 46
Dialogs ..................................................................................................................................................... 47
Tabs and controls .................................................................................................................................. 47
Dialog configuration............................................................................................................................... 48
Create a dialog definition ................................................................................................................... 49
Map the dialog to a paragraph ........................................................................................................... 50
Add the paragraph on a page ............................................................................................................ 50
Best-practice Standard Templating Kit................................................................................................. 51
Contents ................................................................................................................................................ 51
Benefits ................................................................................................................................................. 51
STK components ................................................................................................................................... 52
Site definition ......................................................................................................................................... 52
Areas ..................................................................................................................................................... 54
Template inclusion ................................................................................................................................ 56
Customization........................................................................................................................................ 57
Template prototype ............................................................................................................................ 58
Static HTML prototype ....................................................................................................................... 61
Design with CSS ................................................................................................................................... 64
Layout and grid...................................................................................................................................... 64
HTML structure .................................................................................................................................. 66
Body IDs and classes ............................................................................................................................ 67
CSS configuration .............................................................................................................................. 67
Learn more ............................................................................................................................................ 69
Rendering engine.................................................................................................................................... 70
Steps involved in rendering content ...................................................................................................... 71
Renderers.............................................................................................................................................. 72
Rendering order .................................................................................................................................... 72
Magnolia CMS API................................................................................................................................... 73
Magnolia Context / Aggregation State................................................................................................... 73
Content API ........................................................................................................................................... 74
Components and modules .................................................................................................................... 74
Templating............................................................................................................................................. 74
Configuration mechanisms.................................................................................................................... 76
Properties .............................................................................................................................................. 76
Multiple configurations in the same Web application archive (WAR) .................................................... 77
Components .......................................................................................................................................... 77
Content2Bean ....................................................................................................................................... 78
Where is Content2Bean used? .......................................................................................................... 79
Extending configuration ..................................................................................................................... 80
Observation ........................................................................................................................................... 80
Integration options.................................................................................................................................. 81
Custom filter. ......................................................................................................................................... 81
Custom servlet....................................................................................................................................... 82
Forwarding a request ............................................................................................................................ 83
Custom renderer ................................................................................................................................... 83
Spring (Blossom) module ...................................................................................................................... 83
Direct calls to rendering engine ............................................................................................................. 84
Web services, AJAX and snippets ........................................................................................................ 84
Reading content directly ........................................................................................................................ 84
Internationalization and localization ..................................................................................................... 85
System................................................................................................................................................... 85
Dialogs ............................................................................................................................................... 86
Template scripts................................................................................................................................. 87
Content .................................................................................................................................................. 87
One hierarchy or many ...................................................................................................................... 88
Storing localized content.................................................................................................................... 88
Delivering localized content ............................................................................................................... 89
Authoring ............................................................................................................................................... 90
Unicode ................................................................................................................................................. 92
Security .................................................................................................................................................... 93
Users ..................................................................................................................................................... 93
Groups................................................................................................................................................... 94
Roles ..................................................................................................................................................... 94
ACLs...................................................................................................................................................... 94
Custom login forms................................................................................................................................ 96
Data module............................................................................................................................................. 97
Types..................................................................................................................................................... 98
Dialogs................................................................................................................................................... 99
Content ................................................................................................................................................ 100
2. AdminCentral
AdminCentral is a Magnolia CMS user interface for performing site management and configuration tasks. This is
where administrators and editors work. AdminCentral provides a navigation menu for common tasks on the left
and displays web pages and configuration on the right.
Security. Manage users, groups, roles and permissions. Public user registration is also managed here.
Configuration. Everything in Magnolia CMS can be configured via AdminCentral: cache, menus,
dialogs, workflows, modules...all of it.
Tools. Maintenance tools for logging, importing and exporting, querying, mail and backup.
Packager. A special tool to help with site migration. You can package an entire website or part of it and
move it to a different Magnolia CMS instance.
Magnolia Store. Store for downloading custom modules that extend Magnolia CMS.
3. Authoring
Authoring is the process of writing web content and managing it as part of the website. This includes allowing
non-technical users to contribute content in an easy and intuitive manner.
Content is authored in the browser. The user interface for content authors supports in-place editing. This is a
mode of working where the edited page looks and behaves just like the live page. New paragraphs are displayed
next to existing paragraphs in accurate context. Authors can immediately see what effect adding a new piece of
content has on the page and move the content around if needed.
When you double-click a page in the site tree in AdminCentral, the page is opened for editing.
Each page is made up of pre-defined content areas that can be controlled with templates. Editable content items
within these areas are called paragraphs. Paragraph is the smallest block of content that end users can edit,
delete and move as a unit. Think of paragraph as content that "belongs together". At its simplest, a paragraph
consists of a heading and some text. However, it can contain almost anything: a related image, links to other
articles in the same category, teased content from a sub page and much more. Editable paragraphs are identified
with green toolbars.
10
Clicking the Edit button in the green toolbar opens a dialog. A dialog is an HTML form with fields for editing
paragraph content and metadata. The data you enter into the fields is stored in the repository and ultimately
rendered as a paragraph on the page.
11
4. Instances
Magnolia CMS is distributed as two web-applications, one acting as the authoring instance and the other as the
public environment. This allows for better security, having one application inside your firewall and one outside. It
also enables clustering configurations.
Author instance is where all authors work. It typically resides in a secure location such as behind a corporate
firewall, inaccessible from the Internet. The author instance publishes content to public instances.
Public instance receives the public content and exposes it to visitors on the Web. It resides in a public, reachable
location. You can have more than one public instances, serving the same or different content.
Each instance functions as an independent application but technically they are the same. An author instance can
be configured to function as a public instance and vice versa. The differences are small adaptations in
configuration and security. Security for the public instances is usually managed separately.
12
Magnolia CMS's multi-site feature provides granularity for content control on multi-language and multidomain installations. Administrators have the option to direct content authors to the public site through a specific
domain. Authors edit only the part of the content structure that resides at the specified domain. To ensure a
consistent browsing experience, URLs are adapted to always reflect the domain. You can also configure multiple
domains to access the same instance.
13
14
15
5. Content delivery
Content is published from the author instance to the public instances via activation. Content authors create new
content on the author instance and then activate it. Activation can trigger an optional editorial workflow in which
an editor reviews the changes and approves them for publication. On approval, the new content is transmitted to
the public instance.
5.1. Subscribers
Public instances that receive the activated content are known as subscribers. Any number of subscribers can
subscribe to a single author instance. Subscribers are key to building high-availability, load-balanced
environments since they can be configured to receive targeted content. A subscriber configuration defines the
address of the subscriber and the type of content it should receive.
Example: The image below shows the configuration for subscriber "nbasuperstars-com". The subscriber resides
at URL http://www.nbasuperstars.com:8080/magnoliaPublic. This is the location of the public
instance on the Internet. The subscriber is active which means it will receive content when activation is
executed. Not all content is published to this subscriber, however. It subscribes only to content residing at
path /sports on the author instance. This is an example of mapping a public instance to a subsection of the
content hierarchy.
Subscribers can subscribe to any content item: websites, subsections of websites, configuration settings, custom
data types and data nodes, forums, comments, documents, images and so on.
16
6.1. Repository
A content repository is a high-level information management system that is a superset of traditional data
repositories. It implements content services such as:
Granular content access and access control
Hierarchical, structured and unstructured content
Node types, property types (text, number, date, binary)
Queries (XPath, SQL)
Import and export
Referential integrity
Versioning
Observation
Locking
Clustering
Multiple persistence models
A content repository can store text and binary data (images, documents). You don't need to worry about how the
data is stored. The repository provides a standardized way to store and retrieve it whether it resides in a
traditional database or in a file system.
6.2. Workspaces
Magnolia CMS has one repository, magnolia, which in turn contains several workspaces. There is a workspace
for storing website content, another for user accounts, third for configuration and so on.
Each workspace contains a single rooted tree of items. An item is either a node or a property. Each node may
have child nodes and child properties. Properties cannot have children; they are the leaves of the tree. All of the
actual content in the repository is stored within the values of the properties.
17
The changes you make to nodes and properties are transient in the workspace. Only when the system performs a
workspace save operation are the changes persisted into permanent storage such as a database.
18
19
20
Example: A, B, C and D are nodes. The boxes represent properties with Boolean, numerical, string and binary
values.
21
Application developers benefit from standardization as they don't need to learn several vendor-specific APIs.
Learning one standard API allows them to work with any compliant repository and write code against
it. Businesses enjoy the freedom of choice. Open standards like JCR are the best medicine against vendor lockin; any CMS that supports the JCR standard becomes a viable alternative. Costs associated with switching
vendors are smaller when your content is already the correct format.
22
23
7. Clustering
Magnolia CMS can be configured to run in a clustered environment to provide high availability and load balancing:
High-availability clusters are also known as fail-over clusters. Their purpose is to ensure that content is
served at all times. They operate by having redundant instances which are used to provide service when
a public instance fails. The most common size for a high-availability cluster is two public instances, the
standard Magnolia CMS setup. In such a setup the redundant instance may even be dormant (not
actively serving content) until it is called to service.
Load-balancing clusters connect many instances together to share the workload. From a technical
standpoint there are multiple instances but from the website visitor's perspective they function as a single
virtual instance. A load balancer distributes requests from visitors to instances in the cluster. The result is
a balanced computational workload among different instances, improving the performance of the site as
a whole.
24
In the diagram below, each Magnolia CMS instance uses its own persistent storage (gray databases) for storing
the content of website, DMS and data workspaces. However, the comments workspace has shared content that
is stored in a clustered storage (blue database).
User generated content such as comments written by site visitors is a typical clustering case. Imagine that users
John and Jane request the same web page. A load balancer redirects John to public instance A. When John
leaves a comment on the page, his comment is stored in a workspace that resides in clustered storage. Now Jane
requests the same page. The load balancer redirects her to public instance B. John's comment is immediately
visible to Jane since both instances tap into the same clustered storage.
Other examples of shared content are user accounts, permissions of public users and forum posts. They need to
be available regardless of the instance that serves the page.
25
8. Modules
Magnolia CMS has a modular architecture. A module is a independent component that performs a particular task
or is used to package content and functionality. The system itself is built of modules; AdminCentral, Document
Management System and Workflow are all modules.
You can use modules to:
Create a custom component to address a specific requirement or use case. The Forum module is an
example of this. It provides forums where site visitors can participate in the discussion.
Package an entire website for easy deployment, including customized templates, paragraphs and
content.
Package and deliver a set of assets such as images or documents.
26
A module consists of a set of components packaged in a JAR file. Deploying a module is a matter of copying the
JAR file into the WEB-INF/lib folder and restarting the instance. Magnolia CMS update wizard recognizes the
JAR and installs its contents.
8.2. Configuration
When you start Magnolia CMS, the system identifies available modules by locating each module's descriptor file.
The descriptor is an XML file located in META-INF/magnolia inside the JAR. The name of the file is not
important but we recommend that you follow a naming convention similar to moduleName.xml in your own
modules, such as samples.xml.
A minimal module descriptor looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module SYSTEM "module.dtd">
<module>
<name>samples</name>
<version>4.1.0</version>
</module>
27
The descriptor is quite versatile. You can use it to register servlets and define workspaces too.
After a module is installed it is listed under modules in the config workspace.
Configured items are stored directly under the module node in order to be automatically registered by Magnolia
CMS. As the system monitors configured items, any changes in the configuration of registered items will be active
immediately.
It is common practice to define two source folders: src/main/java for Java classes and src/main/
resources for module-specific resources. This structure is used in every Magnolia CMS module project. Here's
what the folders should contain:
Path
Contents
META-INF
If you have your own custom tab library put the tag library definition file (.tld) here.
META-INF/magnolia
mgnlXML files whose contents you want to be imported into the system when the module
bootstrap/moduleName is installed.
28
mgnl-bootstrapsamples/moduleName
XML samples whose contents you want to be imported into the system when the
module is installed. If property magnolia.bootstrap.samples is set to false
these files are not imported.
mgnl-files
Files in this folder are copied to the web application folder. Folder hierarchy is also
copied.
mgnl-resources
Static resources such as style sheets and JavaScript. They will be available at URI
/.resources/.., for example /.resources/example/style.css.
8.5. Dependencies
Modules can use functionality provided by the Magnolia CMS core code, the Standard Templating Kit and other
modules. When one module uses functionality from another this creates a dependency between modules.
29
You can define run time or install time dependencies but not build dependencies. If you define a dependency on
another module then the target module will be installed and started before your module. A dependency can be
optional which means that if an optional module is not present, installation will still proceed. If the optional module
is present, it will be installed first.
<dependencies>
<dependency>
<name>core</name>
<version>3.6.0/*</version>
</dependency>
<dependency>
<name>cache</name>
<version>3.6.0/*</version>
<optional>true</optional>
</dependency>
</dependencies>
30
Bootstrap files are loaded in the same order as module dependencies, which allows them to override the default
configuration. Files in WEB-INF/bootstrap are loaded last. If the target node already exists, it will be deleted
and overwritten.
Bootstrap files are installed only during module installation, not on updates. This guarantees that any
customizations made to the configuration are not overwritten when the module is updated. This behavior can be
changed by providing a custom version handler.
31
32
9. Magnolia webapp
Java Web Application (webapp) is a collection of servlets, HTML pages, classes and other resources bundled
together and run on a servlet container. The following items can exist in a webapp:
Servlets
JavaServer Pages
Utility classes
Static documents including XHTML and images
Client side classes
Meta information that describes the webapp
Contents
cache/
docroot/
logs/
META-INF/
repositories/
Repository
templates/
tmp/
WEB-INF/
WEB-INF/bootstrap
WEB-INF/bootstrap/common
WEB-INF/bootstrap/author
WEB-INF/bootstrap/public
WEB-INF/classes
WEB-INF/config
33
WEB-INF/config/default
Configuration files
WEB-INF/config/default/magnolia.properties
WEB-INF/config/default/repositories.xml
WEB-INF/config/default/log4j.xml
WEB-INF/config/magnoliaAuthor
WEB-INF/config/magnoliaPublic
WEB-INF/config/repo-config/typeOfPM.xml
WEB-INF/config/jaas.config
WEB-INF/lib
JAR files
WEB-INF/web.xml
34
35
36
Cache. The CacheFilter manages the cache. It checks if a requested resource is already stored in
the cache to avoid recreation of the resource. If the resource is in the cache, then it will be written to the
response and the filter chain stops. If the resource is not found in the cache, then the filter passes the
request on to the CMS part of the chain.
CMS Filter Chain. Next we arrive at the filter chain which does the page rendering and delivery. The
filters in this sub-chain are grouped so they can share a co-bypass definition.
Aggregation. The AggregatorFilter analyzes the request, selects the content from the repository
and stores it in the AggregationState:
Request URI points to Collected information
Page
Paragraph
NodeData
Rendering. Finally, the RenderingFilter is responsible for delivering the requested resource. If the
requested resource is data such as a file then the data is just streamed to the response. If the requested
resource is a page, then the Rendering Filter calls the rendering engine.
The main filter MgnlMainFilter is a single filter which in turn executes a chain of other filters. The chain is not
configured in web.xml but in the config workspace at /server/filters.
37
In the filter configuration you can again have single filters or filter chains. A filter chain consists of a list of single
filters represented by child nodes. A filter node has a class property which specifies the implementing class and
can optionally have an enabled property.
If the filter is enabled, which it is by default, then the filter will be executed. Otherwise the filter will be bypassed. A
filter or a filter chain can define rules to determine when a filter should be bypassed. The configuration of
bypasses is done using Voters. For more, see Magnolia CMS core filters.
38
11. Templating
All Web pages created with Magnolia CMS are based on templates. Templates ensure that page structure and
presentation remain the same while the content varies from one page to another. For example, an event template
helps you generate event pages that look and feel the same but display a different unique event each.
The system generates pages by merging a template with corresponding content from the repository. The position
and inclusion of each paragraph on the page is defined by the page template. In many instances, the page
template will allow authors to choose from a number of different paragraph types in a single content area.
39
Numbered items:
1. An article about basketball in the New York Times Sports sections has the following page properties:
title rendered as an H1 element on the page, "Bulls and the Thunder Make a Stand"
date and author rendered on the dateline
abstract to provide an introductory paragraph
2. The next element on the page is the main collection which contains paragraphs.
3. Paragraph 0 is a text paragraph ("LeBron James scored 13...") with a matching image. The image file
and its caption and credit are stored in the document management system (DMS).
4. Paragraph 00 consist of text and an optional subtitle element "THUNDER 101, LAKERS 96".
5. The page ends with a footer singleton paragraph which is a kind of placeholder. It can contain content
such as a copyright statement.
40
41
The renderer includes the results on the page as instructed by the template script. The script tells the renderer
where to place the content. It contains placeholders for content attributes such as headings, images and the
results of the business logic execution.
A Web page is the output of the rendering process where template and content are combined.
42
43
[@cms.newBar contentNodeCollectionName="mainColumnParagraphs"
paragraph="samplesTextImage,samplesDownload,samplesLink" /]
editBar. Displays a toolbar that allows you to edit a paragraph. This tag is often used within
contentNodeIterator, which in turn will set all relevant parameters automatically.
[@cms.editBar /]
contentNodeIterator. Iterates over a contentNode collection. This tag is used whenever you want to
loop over content, typically paragraphs. Parameter contentNodeCollectionName contains the name of
the contentNode you are looping over. The contentNodeCollectionName is created in the first place by
providing the name to a newBar. This will result in elements being created within that contentNode, and
allows you to loop over them later.
[@cms.contentNodeIterator contentNodeCollectionName="main"]
[@cms.includeTemplate /]
[/@cms.contentNodeIterator]
includeTemplate. Delegates the task of rendering a paragraph to an appropriate ParagraphRenderer
or includes JSP. When used within contentNodeIterator the parameters are provided automatically by
the loop.
[@cms.includeTemplate contentNode=content.footer /]
44
45
Purpose
content
page or actpage
Current page exposed as a map like cms:setNode. This attribute is called actpage in
JSP because the name page is reserved.
def
model
actionResult
The result of the model's execute method. This string can be used to determine the
template (in the definition) or in the template itself.
mgnl
An object providing access to various components and utility methods, for example to
create links. See MagnoliaTemplatingUtilities.
ctx
state
Current AggregationState.
stk
i18n
Messages from the current message bundle like the "Read on" message. i18n["key"]
46
12. Dialogs
The authoring system uses dialogs for content contribution and control. A dialog is an HTML form with input fields.
Authors type content into the input fields and the dialog stores it in the repository. In addition to content entry, the
system provides standard dialogs for page properties, data nodes, users, roles, workflow notifications and many
other editable items. It's a very agile mechanism; you can create your own dialogs and customize the standard
dialogs.
47
The second tab, "Image", allows you to select an image to accompany the text. An option button (radio button)
control is used to choose between uploading the image from the local computer and selecting it from the
document management system. For more examples controls available in Magnolia CMS, see the list of available
controls on the documentation site.
48
49
50
13.1. Contents
Standard Templating Kit includes:
Reusable paragraphs
A mechanism for assembling page templates through definition rather than coding.
A mechanism for creating custom paragraphs without affecting or even touching the page templates that
use them.
A set of use case driven page templates which can be used as such, modified or replaced with your own
templates.
Clear and clean separation of HTML, client-side functionality (jQuery), content (JCR), business logic
(Java) and design (CSS). A static HTML prototype is provided for designers who prefer to start with CSS
and a basic HTML wire-frame.
Support for multiple site configurations
13.2. Benefits
Out-of-the-box solution. The use case driven page templates shipped with the kit provide a quick start
to building your website. The kit gives you a significant head start since much of what you need is
already provided. Less effort generally means you will be faster but more importantly it means your
project will be more predictable. You have less uncertainty, which for project managers means less risk.
Use case based templates. Templates and paragraphs included in the kit are all based on real-life use
cases. Templates include home, section, search, news, events, contact form, article and many more.
Numerous ready to go live paragraphs are also available such as content paragraphs, teasers, stages,
promos, event lists and more.
Configurable layout and style. The look and feel of the website is controlled mainly by a single CSS
file. Since the HTML structure is designed to be styled by CSS, the look and feel of the site can be
changed without touching the templates. And since CSS is configured in the site configuration, you can
create a custom CSS for each site.
Role-based development. Designers and CSS developers don't necessarily need to know anything
about Magnolia CMS in order to create a compatible a site design. They can start with the static HTML
prototype shipped with the system. From the prototype they can pick an HTML structure that is a close
match to their original design and modify it further. Style sheets are also provided.
Accessibility. The generated HTML adheres to W3C WCAG2m and German BITV accessibility
standards. Invisible navigation messages for vision-impaired users are included.
51
Extensibility. As the template and model are separated, you can modify the templates or extend the
model. Many aspects can be configured in the template or site definitions without writing code. For
example, you can define paragraphs that are available for individual page templates and their
positioning.
52
Internationalization and localization (i18n). Enabling i18n support in the site definition allows authors
to write foreign-language content. When enabled, the mainBar has a language drop-down. Dialogs
display the language identifier (en, fr, de...) to make it clear what language should be entered. Foreignlanguage content is served to visitors at a specific URL, such as www.mywebsite.com/de/
article.html. Redirecting visitors to the language-specific URL is configured in the web server.
53
13.5. Areas
The page templates shipped with the Standard Templating Kit organize the page layout using areas. These are
controllable blocks, typically rendered as div elements, that help you customize the template structure.
Typically each area is wrapped in a div element, having a correspondingly name ID attribute, for example main
area has id=main.
Note: An area is not the same as a paragraph. Paragraph is a content element with an associated paragraph
definition while areas are structural elements in the template script. In fact, areas are dynamic include directives
which together compose a single template script.
54
The following diagram illustrates some key elements you will find on a page based on the article page
template. The box captions indicate div element ID attributes. For example, the element that renders the vertical
navigation on the left is <div id="nav">.
Note! This is not a complete set of areas. There are further smaller div elements to handle logo and breadcrumb
placement, for example. Other page templates again offer drastically different layouts, using elements such as
stages and platforms to promote content.
55
56
13.7. Customization
This dynamic approach allows you to combine your own templates with those of STK. Use the STK templates as
much as you can to speed up development. When you can't move further without customizing, create your own
template.
Three customization options:
Change the main template used by all STK templates if you want to change the main HTML structure.
This is configured in /prototype/templatePath. The default value is /templating-kit/
templates/main.ftl.
Reconfigure template scripts used for specific areas.
All further dynamic includes can continue to be reused elsewhere, and in your custom template if you need them.
In most cases you would copy an existing template. In the site definition, override the used template by setting
the template attribute to the customized one.
Tip: When using Freemarker, you don't need to put the template script in the template workspace. You can load
them from your module JAR. This is what we recommend for production projects.
57
58
Description
htmlHeader
navigation
Configures navigation. The static HTML prototype includes a page that shows you how the
various navigation menus look at all depths. It allows the CSS designer to see at single glance
whether test CSS is correct.
navigation/ Horizontal navigation, including the number of levels and template script used.
horizontal
navigation/ Vertical navigation, including the number of levels and template script used.
vertical
header
breadcrumb
mainArea
Configuration of the main area. In the prototype the area is used for basic content templates
such as articles
extrasArea
Extras area is typically located on the right hand side. This configuration is site-wide and
contains a list of paragraphs available as extras.
footer
59
This is what happens when a template prototype is merged with a concrete template:
1. Template prototype is the basis.
2. Concrete template definition adds and overrides.
3. The result is exposed as the template definition (def) to the template script
stkHome defines which paragraphs are available in the mainArea. It also uses a custom template script for
the mainArea and disables the extrasArea. The prototype defines the main template (main.ftl) and preconfigures the main and extras areas.
60
61
The static prototype contains an index page which serves as the starting point for paragraph and page templates
provided with the STK.
62
Navigation at all levels is also available at a single glance. Developing a CSS against this view saves a lot of time
when you can see all variations right away.
63
Magnolia CMS supports role-based development by letting everyone work on what they are good at. Designers
can change the appearance of a page without having to change a template. Likewise, templates do not become
cluttered with design fragments.
64
The technique used to achieve this is CSS media queries and JavaScript. For older browsers that do not
recognize JavaScript it is completely unobtrusive and the default CSS resolution is 1024 x 768 px.
65
66
67
2. In Templating Kit > Themes, a theme definition contains a link to each sheet. It also defines the
targeted media type (screen, print etc).
Note that in the media property you can use CSS3 media queries to test the features of the output
device. The sheet is applied if the test evaluates to true. In the example above we evaluate the minimum
width of the viewport before applying the wide sheet.
68
3. In the htmlHeader page template, a Freemarker #list directive collects the style sheets from the pop
theme. It creates link elements and writes them in the page head element.
[#list model.site.theme.cssFiles as cssFile]
<link rel="stylesheet" type="text/css" href="${cssFile.link}"
media="${cssFile.media}" />
[/#list]
Tip: In real production projects it is recommended that CSS are stored in the module JAR. They have to reside in
the mgnl-resources folder. In that case the link property will point to /.resources/pathToCss.
69
70
71
14.2. Renderers
A renderer is a Java class library that understands a particular templating language and produces text output. For
example, the Freemarker renderer understands Freemarker tags and JSP taglibs and produces output in HTML,
XML, RTF, Java source code and a few other formats. A renderer is not an end-user application but rather
something programmers can embed into their products.
Magnolia CMS ships with JSP and Freemarker renderers. Other popular successfully integrated template
languages are Velocity (similar to Freemarker but lighter) and Coldfusion.
While Magnolia CMS tag library is a native JSP tag library, the tag logic is also available as Java classes. Any
renderer that knows how to call a Java method can theoretically be used to render authoring UI components. The
experimental Templating Components module packages the classes and provides the logic as independent
components. If you want to attempt integrating your favorite Java-aware renderer, the module is included in the
add-ons folder of the Magnolia CMS bundle or available as a separate download.
72
73
15.4. Templating
RenderingEngine. Entry point for the rendering.
render(content, definition, writer). Render the content by using the passed
definition.
render(content, writer). Determines the definition from the content automatically.
74
75
16.1. Properties
Magnolia CMS is primarily configured using properties. Properties come from multiple different sources,
processed in the following order:
Source
Location
Path
1. Bean properties
magnoliacore.jar
/mgnl-beans.properties
2. Module properties
module descriptor
<properties>
<property>
<name>defaultPublicURI</name>
<value>redirect:/
help.html</value>
</property>
</properties>
Web application
WEBINF/config/magnolia.properties
Web application
WEB-INF/config/default/
magnolia.properties
Web application
WEB-INF/config/(webapp)/
magnolia.properties
Web application
WEB-INF/config/(servername)/
magnolia.properties
Web application
WEBINF/config/(servername)/(webapp)/
magnolia.properties
8. System properties
JVM (-Dx=y)
Sources processed earlier may be overridden by sources processed later. The distribution of properties into
several sources and the processing order allow flexible customization.
76
16.3. Components
Magnolia CMS uses components provided by a Components service. Magnolia properties can be used to define
which concrete class should be used to instantiate a certain component. The property key is the interface or class
name and value is the concrete class or a path which maps to the config workspace. If the value is a path then
the Content2Bean mechanism is used to build the instance.
77
Example configuration:
# Map to a path in the config workspace
info.magnolia.cms.i18n.I18nContentSupport=/server/i18n/content
# Concrete class implementing the interface
info.magnolia.module.ModuleManager=info.magnolia.module.ModuleManagerImpl
Some default classes are defined in file mgnl-beans.properties provided by the core JAR. The values can
be overwritten and defined in the module descriptor or properties configuration files.
Examples of components:
SecurityManager. Used to read users, groups and roles.
TemplateManager. Provides a template definition used in rendering.
ModuleRegistry. Holds instances and definitions of modules.
To retrieve a component you should use the Components service class. Most components are singletons.
I18nContentSupport i18n = Components.getSingleton(I18nContentSupport.class);
16.4. Content2Bean
Most of Magnolia CMS configuration is stored in the config workspace. A mechanism known as Content2Bean
is used to transfer the configuration from the workspace into a Java object. Content2Bean populates a JavaBean
with the content of a repository node, including sub nodes.
With Content2Bean's "setter" and "adder" methods you can populate configuration collections and maps. The
methods can handle simple data types (String, int, float, double, Boolean), custom data types, collections and
maps with key-value pairs.
The class used to instantiate an object through the Content2Bean mechanism is determined through reflection or
by explicitly referencing a class in the class node data. By referencing a specific class you can override Magnolia
CMS default configuration and implement your own caching behavior, security mechanism and so on.
78
Numbered items:
1. config is the entry point of the transformation. In the module descriptor we define that SampleConfig
class is used. text and number properties will be set.
2. sub is a sub bean. The class is determined using reflection if not explicitly defined.
3. items is a collection. The corresponding add method is used to determine the class and populate the
collection if existing.
4. item2 is a special item. It has its own class and additional properties.
5. parameters is a map of key-value pairs.
79
16.5. Observation
Observation is a Java Content Repository feature that allows applications to register interest in events that
change a workspace and then monitor and respond to those events. The observation mechanism dispatches
events when a persistent change is made to the workspace. Magnolia CMS uses observation heavily. For
instance, observation is used to reload module configurations and to reload all objects.
The components provided by Magnolia CMS are proxy objects to allow re-initialization of the components upon
configuration changes.
80
Tip: If the filter wraps the response like we do in the Cache filter you can also post-process the content.
81
82
83
Pre-execution of paragraphs. Enables the use of redirects and forwards in the execution of a
paragraph. The execution is bound to a specific paragraph which allows you to have multiple instances
of the same paragraph on the same page.
More information is on the Blossom module wiki page.
84
18.1. System
The AdminCentral user interface for content authors is available in 16 languages: Chinese (China), Chinese
(Taiwan), Czech, Dutch, English, French, German, Indonesian, Italian, Japanese, Norwegian, Portuguese,
Portuguese (Brazil), Russian, Spanish and Swedish.
85
Supported languages are configured in /config/i18n/system. Each language has a country and language
property so you can define regional variations too, such as zh_TW for traditional Chinese or pt_BR for Brazilian
Portuguese.
One of the languages is always a fallback language. If no target language content is found, the system displays
content in the fallback language instead.
Labels for user interface elements such as dialogs, tabs and buttons are stored in a message bundle. The bundle
is a collection of properties files inside a module JAR. You can retrieve a particular label from the properties file by
referring to it with a key in the UI element's configuration. For example, the reference
key dialogs.paragraphs.content.stkTextImage.tabText.label matches a label for the "Text" tab in
the Text and Image dialog. It is retrieved from the message_en.properties file included in the Standard
Templating Kit module:
dialogs.paragraphs.content.stkTextImage.label=Text and Image
dialogs.paragraphs.content.stkTextImage.tabText.label=Text
dialogs.paragraphs.content.stkTextImage.tabText.subtitle.label=Subheading
Translation of user interface text to another language is a community project coordinated by Magnolia
International Ltd. Community volunteers choose a language to translate and work in Google Spreadsheets. Their
contributions are built into the properties files that ship with the system. We trust enthusiastic users to do a better
job translating the UI than a professional translator who is not familiar with the system.
18.1.1. Dialogs
For dialogs you can define a i18nBasename data node which determines the message bundle to use. Like
above, the bundle contains properties files which have strings for dialog elements. Instead of entering text
manually you can use a key. The key will be substituted by the value from the property file.
86
Here's an example of the Text and Image dialog definition with i18nBasename. The description and
label properties use keys instead of manually entered strings.
18.2. Content
Content level internationalization handles the storing of localized content in the JCR and serving it at a languagespecific URL such as mysite.com/de/welcome.html. This option is enabled by default. Language variations
are stored in a single content hierarchy. You have the option to disable the localized content storage and create a
separate site hierarchy for each locale instead.
87
88
URL
www.mywebsite.com/de/article.html
French
www.mywebsite.com/fr/article.html
Spanish
www.mywebsite.com/es/article.html
Correspondingly, the HTML element on the public page identifies the language with standard lang and
xml:lang attributes since pages based on STK templates adhere to an XHTML doctype.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/
xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
Magnolia CMS does not redirect visitors to the localized URL automatically. You need to configure this behavior
on the web server. There are various strategies how you might want to do this. Note that these are not provided
out-of-the-box:
Allow the visitor to select a language or region from a dropdown, then redirect them to the correct URL.
This is a common strategy on airline websites. Airlines serve customers in many countries and
languages, and allow users to select their home country while traveling.
Detect the visitor's origin from their IP or the referring page, then redirect them to the localized site
automatically.
Detect the visitor's preferred locale from their browser settings, then redirect them to the localized site
automatically.
89
18.3. Authoring
This level of internationalization adapts the authoring interface to support localized content entry. The default
implementation adds a language dropdown in the mainBar and displays a two-letter language identifier (en, ge, fr
etc.) next to field labels in the content entry dialog.
Enabling i18n authoring support allows authors to write foreign-language or regionally targeted content. The
relevant configuration node is /config/server/i18n/authoring.
90
Once enabled, the mainBar displays a language dropdown. Selecting a language from the dropdown defines the
content entry language for paragraphs and properties on the page.
Dialogs reflect the choice by displaying an identifier (en, fr, de...) next to field labels. This makes it clear which
language should be entered.
The language dropdown and the identifier are Magnolia CMS default implementations. You can alternatively
develop your own strategy for localized content entry. You could for example create a tab for each language in
the dialog. If the number of supported languages is not very large, say 3 or 4, this might work fine. We opted for
the field label strategy because it works well with a large number of languages and keeps UI changes minimal.
91
18.4. Unicode
Magnolia CMS supports UTF-8 character encoding for Unicode. UTF-8 is able to represent any character in the
Unicode standard, yet is backwards compatible with ASCII.
To enable Unicode support for content node and page names, set the magnolia.utf8.enabled property in
magnolia.properties. This allows you to handle non-ASCII characters in URLs, for example.
# Activate UTF-8 support to pages
magnolia.utf8.enabled=true
Sites built using STK templates identify the encoding as UTF-8 with an HTML meta element.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
Here is an example of a Russian travel site built with Magnolia CMS. Russian uses the Cyrillic alphabet included
in UTF-8.
92
19. Security
Security is controlled with a built-in access management system. The purpose of this system is to:
Authenticate. Reliably and securely determine who is using the system and provide them with means to
sign into the application.
Authorize. Ensure that users have the permissions to do the actions required such as editing pages or
creating categories.
The system is based on the Java Authentication and Authorization Service (JAAS). You can set permissions for
all types of users whether real people or processes, and control access to resources such as Web pages,
documents, data, forums and templates. Permissions are controlled through a combination of users, groups, roles
and ACLs in AdminCentral.
In a small site you can manage users and groups in Magnolia CMS. On a larger site (hundreds of users) it is
better to manage users and groups in an enterprise-grade user directory such as LDAP. You would define roles
and ACLs in Magnolia CMS but manage users and groups in the external system. Magnolia CMS supports
directories via the LDAP Connector, a standard JAAS login module.
19.1. Users
A user is an account that identifies the person accessing Magnolia CMS. In addition to a username, the system
stores the user's full name, password, language preference and email address by default. Users inherit their
permissions from the groups and roles they are attached to. Users are organized as follows:
Users can have both roles and groups.
Groups can have roles.
Roles can have only ACLs.
Permissions are defined in the ACL. Users inherit permissions from the roles and groups assigned to them.
On a small site you can manage users and groups in Magnolia CMS. On a larger site with hundreds of users it is
better to manage users and groups in an enterprise-grade user management infrastructure such as Microsoft
Active Directory. In such case you would define roles and ACLs in Magnolia CMS but manage users and groups
in the external system.
93
19.2. Groups
Users with similar privileges are grouped together. The purpose of a group is to define settings for the group as a
whole rather than each individual user. Permissions that apply to the group are inherited by its users. By
assigning a role to a group, all users in the group will inherit the permissions granted to the role.
19.3. Roles
A role is a function a user performs in the management of a Magnolia CMS website. It reflects the actions and
activities assigned to or required or expected of a user. For example, the role Editor is responsible for day-to-day
editing of content displayed on the site. Permissions granted to the Editor role allow users in this role to edit
content and submit it for review. The role Publisher on the other hand is tasked with reviewing content and
publishing it from the authoring instance to public instances. Note that role names and permissions are completely
configurable to match your actual requirements.
The standard installation of Magnolia CMS includes default definitions of roles, groups and users. A sample
structure is provided to demonstrate a typical setup, and it can be adapted.
19.4. ACLs
Access to resources is controlled with an access control list (ACL). An ACL consists of one or more rules where
permissions are applied to the controlled resource. The ACL itself defines what permission is granted. Attaching
the ACL to a role defines who has the permission. Any groups and users that belong to the role either directly or
through groups have the permissions granted in the ACL.
Example of ACL rules defining permissions to access a site:
94
Scope
Path
Read/Write
Sub page
/siteA/news
The power of ACLs is in the combination of rules. The following ACL first denies access to the complete website,
then specifically allows read access to /siteA and write access to subpages under /siteA/news. Users whose
access is controlled with this ACL can see /siteA and all its subpages but can edit only pages under /siteA/
news.
Permission
Scope
Path
Read only
Ready only
Read/Write
Sub pages
/siteA/news
Note: For technical reasons you can only select "Selected and subpages" or "Subpages" scope in the website
workspace, not "Selected page only". When you need to restrict user access to just the root node (/), use the
dollar character ($). The dollar character means "end the expression here". It allows the user to expand the site
tree in AdminCentral. Then create further rules to grant explicit access to paths (/siteA) the user should be able
to access.
95
96
97
20.1. Types
Start by creating a new data type. Type is a content node that acts as a label for the data such as "products",
"clients" or "books". Types can be hierarchical, consisting of subtypes.
Magnolia CMS ships with four sample data types:
Company is a hierarchical type consisting of departments and employees.
RSS Aggregators allows you to aggregate feeds from multiple sources.
Contact is a basic example of how to store personal details for use on pages.
Category shows how to create a taxonomy of terms that can be used to tag content.
Types have to be registered before they can be used. This is done automatically when you create a new type by
hand. When you introduce new types with a custom module, bootstrap the types first before bootstrapping their
dialog configurations and content. The Data module provides a special install task to do this.
98
20.2. Dialogs
To edit the data you need a dialog. You can build the dialog using standard Magnolia CMS controls such as text
boxes, tabs and date pickers, or create your own custom control.
Here is a definition for a dialog used to edit contacts. The definition is on the left and the rendered dialog on the
right.
99
20.3. Content
The actual data is stored as folders and properties at the repository level. You can view the underlying structure
with the JCR Browser. If a data type allows hierarchical organization, the content item folders have subfolders
correspondingly.
100
21. Cache
Magnolia CMS employs a web cache to store server responses so that future requests for the same content can
be served faster. Using a cache reduces the amount of information that needs to be transmitted across the
network, easing the bandwidth and processing requirements and improving responsiveness.
101
Client (browser) cache policy defines how long the browser may cache a document. The time is
passed to the browser in the response header. The default FixedDuration option instructs the
browser to cache the document for 30 minutes. Another option is Never which tells the browser to do
nothing.
Flush policy defines when to flush the cache. The default configuration observes changes in a
repository and flushes the cache if new or modified content is detected. You can flush the cache
completely, partially or not at all. Multiple flush policies can be registered. Each module can register its
own flush policy (or multiple policies) and be notified about new or modified content in each repository.
Executors are actions taken once a caching decision has been made. There are three possible actions.
useCache retrieves the cached item from the cache and streams it to the client, store stores the
response in the cache for future use, and bypass skips caching altogether.
102
If content has been modified or it does not exist in the cache, the filter passes the request to the server cache
policy. Server cache policy analyses the request and replies with the expected behavior. Based on the expected
behavior the filter invokes the appropriate executor. This mechanism allows you to add and remove executors
and use them by changing the current cache policy to a different one.
103
22. Workflow
Magnolia CMS ships with a basic "four-eye" editorial content workflow. Authors and editors come across this predefined workflow for the first time when they activate content. Activations are submitted to a workflow queue for
approval. A publisher can examine the workflow item, see what the changes are, who made them and when, and
decide whether to publish the modified content to a public instance.
The key point about the default workflow is that authoring and editorial review happen on the author instance.
Content is published to public instance only when the workflow is completed.
104
22.1. Engine
Magnolia CMS uses the cross-platform OpenWFE workflow engine. OpenWFE allows extensive workflow
customization, making it possible to integrate Magnolia CMS into your legacy business processes. You can define
your own activation and publishing workflows with as many stages and participants as needed.
The engine supports:
Linear modeling and approvals
Branching and merging
Conditionals such as IF and multi-choice
Auto-escalation
Email notifications
Pre-defined workflows
Workflows are defined in XML. You can use a third party editor with syntax highlighting to enhance the editing
experience. Graphical tools exist but experience using them with Magnolia CMS is limited. Generally we assume
that workflows are defined by suitably skilled people. OpenWFE provides a flexible set of rules to accommodate
business requirements and the XML markup is clean.
<process-definition name="activation" revision="j0.0.2">
<sequence>
<set field="activator" field-value="userName"/>
<!-- go to publisher first -->
<to-publisher/>
<!-- will loop if rejected -->
<if test="${field:action} == reject">
<revision-round/>
</if>
<log message="activate: ${field:action}"/>
<!-- if the last action was proceed: activate-->
<if test="${field:action} == proceed">
<activate/>
</if>
</sequence>
22.2. Participants
A participant is a reference to a user or program that takes part in the workflow. Participants are identified in the
workflow definition by their name. OpenWFE understands four kinds of participants:
user-username
group-groupname
role-rolename
command-commandname
105
So if you want to route a publication approval to user "john", make sure that the process definition states:
<participant ref="user-john" />
A participant acts on the workitem by completing the required task such as reviewing a page change.
Permissions to view workflow items are controlled through Magnolia CMS user rights management. This allows
an administrator or workflow supervisor see workitems assigned to other users. Their inbox effectively functions
as a "dashboard", displaying the status of the workflow process.
Since commands and processes can participate in a workflow, you can send email notifications on pending
workitems. A workflow command can be attached to any event such as move page, delete page, activate, rename
etc.
106
Each module can provide its own commands. Commands are configured in
/modules/moduleName/commands/catalogName/commandName.
A command name is linked to a Java implementation. For example, you could write a command that encapsulates
the decision who (or which group or role) should receive the workitem next. The name of the "real participant"
could be placed in a workitem field such as receiver.
<sequence>
<participant ref="command-determinereceiver" />
<participant field-ref="receiver" />
</sequence>
107
23. Resources
Here's what you should do next:
Visit Magnolia home page
Download Magnolia CMS and the Standard Templating Kit
Read official documentation and create an account on the community wiki.
Join the users mailing list,
Follow us on Twitter
108