The 5.7 branch of Magnolia reached End-of-Life on December 31, 2023, as specified in our End-of-life policy. This means the 5.7 branch is no longer maintained or supported. Please upgrade to the latest Magnolia release. By upgrading, you will get the latest release of Magnolia featuring significant improvements to the author and developer experience. For a successful upgrade, please consult our Magnolia 6.2 documentation. If you need help, please contact info@magnolia-cms.com.
The SiteMesh module integrates the SiteMesh 3 decoration and Web application integration framework with Magnolia. If you intend to use SiteMesh only as the mechanism for dynamic page caching you can skip this page after its installation and continue with Advanced Dynamic Page Caching.
SiteMesh intercepts requests to any static or dynamically generated HTML page requested through the web-server, processes the content and then merges it with one or more decorators to build the final result." – SiteMesh 3
Installing
<version/>
in the dependency.Uninstalling
- Remove the
/server/filters/sitemesh
node. - Remove the
/server/rendering/engine/listeners/sitemesh
node. - Remove the
/modules/sitemesh
node and its subnodes. - Shut down Magnolia, remove the SiteMesh module JAR (
magnolia-module-sitemesh.jar
) fromWEB-INF/lib
and start up Magnolia again.
Filter
SiteMesh filter processes by default only text/html but can be configured to process any text resources such as css or javascript: true info.magnolia.cms.filters.FilterDecorator true info.magnolia.voting.voters.ResponseContentTypeVoter true text/html
Decorators
The decorator contains the common layout and style that should be applied to the pages in the web application". – Getting Started with SiteMesh 3
If you have samples and demo/project installed, you can find SiteMesh sample under /demo-features/modules/sitemesh-sample.html and its decorator under /demo-features/modules/sitemesh-sample/decorator.html. You can configure more that one decorator per path (and of course use regular expression for path). You can find the templates under templates:/sitemesh-sample.
Decorator selector chooses the decorators for pages. MetaTagBasedDecoratorSelector is used by default. true info.magnolia.cms.filters.FilterDecorator info.magnolia.sitemesh.config.MagnoliaConfigurableSiteMeshFilter org.sitemesh.config.MetaTagBasedDecoratorSelector /demo-features/modules/sitemesh-sample.html /demo-features/modules/sitemesh-sample/decorator.html
Content processor
Processes the text content tag by tag. You can configure sets of rules under tagRuleBundles. You can use the bundles provided by SiteMesh 3.0.0. Just use info.magnolia.sitemesh.content.TagRuleBundleWrapper as class, create node wrapped and set the bundle class as the property class: true info.magnolia.cms.filters.FilterDecorator info.magnolia.sitemesh.config.MagnoliaConfigurableSiteMeshFilter info.magnolia.sitemesh.content.MagnoliaContentProcessor info.magnolia.sitemesh.content.TagRuleBundleWrapper org.sitemesh.content.tagrules.html.CoreHtmlTagRuleBundle
Tag rule bundles
Because the bundles provided by SiteMesh 3 are fixed sets of rules, Magnolia offers you also configurable info.magnolia.sitemesh.content.MagnoliaTagRuleBundle. You can dynamically add info.magnolia.sitemesh.content.MagnoliaRules to this bundle: true info.magnolia.cms.filters.FilterDecorator info.magnolia.sitemesh.config.MagnoliaConfigurableSiteMeshFilter info.magnolia.sitemesh.content.MagnoliaContentProcessor info.magnolia.sitemesh.content.MagnoliaTagRuleBundle baseURL
in the InjectUriRule
node.
Set /server/filters/sitemesh/decoratedFilter/contentProcessor/tagRuleBundles/magnolia/rules/InjectUriRule/tag/baseUrl
to http://localhost:8080${contextPath}
, for example.
- Request:
https://demo.magnolia-cms.com/
. - Fragment request:
https://localhost:8080/magnoliaPublic~mgnlArea=main~
.
Site-specific configurations are not taken into account.
If baseURL
is not set, the base URL of the current request is used:
- Request:
https://demo.magnolia-cms.com/
. - Fragment request:
https://demopublic.magnolia-cms.com/~mgnlArea=main~
.
Rules & Tags
Every info.magnolia.sitemesh.content.MagnoliaRule holds tag. info.magnolia.sitemesh.content.AbstractTag processes a html tag. You can implement for example a tag which replaces all occurrences of <b> with <s>. Set includeInContent=true on rule if you don't want to replace the original tag but only append new content after it. Add content node named tagTypes to a tag to tell which tag types you want to process. All types (open, close, ...) will be processed if no tagTypes node will be added. true info.magnolia.cms.filters.FilterDecorator info.magnolia.sitemesh.config.MagnoliaConfigurableSiteMeshFilter info.magnolia.sitemesh.content.MagnoliaContentProcessor info.magnolia.sitemesh.content.MagnoliaTagRuleBundle true info.magnolia.sitemesh.content.MagnoliaRule info.magnolia.sitemesh.content.inject.InjectUriTag mgnl:injecturi false open
Out of the box rules | ||
---|---|---|
class | description | configurable fields (default values) |
info.magnolia.sitemesh.content.inject.InjectTag | Tag for any text injection. | contentToInject (empty string) |
info.magnolia.sitemesh.content.inject.sample.InjectAdmincentralButtonTag | Tag injects admincentral button to navigate to admincentral when accessing pages outside of admincentral. | contentToInject (empty string) |
info.magnolia.sitemesh.content.inject.InjectUrlTag | Tag for injection of content retrieved by URL specified as argument target of this tag.
| readTimeout (600000) connectTimeout (10000) bufferSize (4096) |
info.magnolia.sitemesh.content.inject.InjectUriTag | Tag for injection of content retrieved by URI (that means a URI which points to the same webapp) specified as argument target of this tag. The current original request is used to create URL. Other arguments are set as request headers such as
| readTimeout (600000) |
Fragment Injection Listener
true info.magnolia.module.advancedcache.rendering.FragmentInjectionListener false RELATIVE_TO_CONTEXT_ROOT </mgnl:injecturi><mgnl:injecturi target="${targetPath}" X-Magnolia-Cache="ttlValue=${ttlValue},CacheKeyGenerator=${CacheKeyGenerator},">