martes, 18 de febrero de 2014

Magnolia Blossom Module, STK Module or both?

First a small introduction, quoting from our documentation pages:

Standard Templating Kit (STK)
"The Standard Templating Kit is a production-ready website framework that provides best practices and templates for common use cases. It includes ready-made functionality that can be extended for custom designs and content output. The STK adheres to best practices in CSS, semantic web and HTML, including HTML 5 video and forms support. It also provides a mobile variation which makes your STK-based sites available to mobile devices."
Blossom Module
"The Blossom module is the Spring integration for Magnolia CMS. Blossom enables you to create editing components that display a high level of dynamic behavior. These components can be used by editors to create truly interactive web pages. For example, the Spring Framework application stack makes it easier to develop integrations with business systems, so that they fetch the information that you want to present in your pages. As Blossom is built on the Spring Web MVC, familiarity with this framework will ensure a smooth experience working with the module."
I could be using all the templates, components and functionality provided by STK and create new ones within a Blossom module.

Let's see how:

We need to create our project, I always go for creating a webapp project with our maven archetype. Once we have the webapp project we use the archetype to create a blossom module.
In order to make all the STK functionalities available in our Blossom module we need to modify the file   blossom-servlet.xml that has been generated by the maven archetype in the resources folder of our new Blossom module and add the STK renderer context attributes as shown below.

This configuration will allow us to access to the SKT functionality from our template scripts.
Now, how we access to that functionality from the templates model/controller?
We can access to them using one of our API methods, see:

This would be the easiest way to access to STK functionality as all the components loaded by Guice are already available.

See how you reference a Blossom component within a STK template

See how this component is defined within the Blossom custom module: