...
Template defines headerNav container
Code Block |
---|
|
<nav class="top-menu">
<div class="container no-padding">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 no-margin">
<wicket:container wicket:id="headerNav">
[header nav]
</wicket:container>
</div> |
StandardHeader component populates this value with content body of header_nav_include.
Code Block |
---|
|
String content = contentServiceFacade.getContentBody(
"header_nav_include", getCurrentShopId(), getLocale().getLanguage());
return new Label("headerNav", content).setEscapeModelStrings(false); |
...
Define container element in Wicket HTML template, e.g. myCmsContainer
Code Block |
---|
|
<wicket:container wicket:id="myCmsContainer">[my cms container]</wicket:container> |
Add container element as Label containing body of the CMS content object, retrieved by content service using URI, e.g. "my_cms_include"
Code Block |
---|
|
String content = contentServiceFacade.getContentBody(
"my_cms_include", getCurrentShopId(), getLocale().getLanguage());
addOrReplace(new Label("myCmsContainer", content).setEscapeModelStrings(false)); |
If we want dynamic content to be included the java code should be updated to use dynamic body and supply all parameters to be used in this dynamic content.
Code Block |
---|
|
final Map<String, Object> contentParams = new HashMap<>();
...
// populate contentParams map
...
String content = contentServiceFacade.getDynamicContentBody(
"my_cms_include", getCurrentShopId(), getLocale().getLanguage(), contentParams);
addOrReplace(new Label("myCmsContainer", content).setEscapeModelStrings(false)); |
...
Configure CMS object with URI
Textbox |
---|
Body | [shop code]_my_cms_include |
---|
|
.
Configuring include on
...
SFG
...
...
Say we want to create CMS include with "my_cms_include" that will be included in our custom component.
Use
...
Textbox |
---|
Body | ctx.content('my_cms_include') |
---|
|
for plain HTML or
...
Textbox |
---|
Body | ctx.dynamicContent('my_cms_include', |
---|
|
...
...
...
For example template which uses include would look like so:
Code Block |
---|
div('class': 'container') {
mkp.yieldUnescaped(ctx.content('my_cms_include'));
} |
Code Block |
---|
div('class': 'container') {
mkp.yieldUnescaped(ctx.dynamicContent('my_cms_include', ['p1':'value1', 'p2object': myObject]));
} |
SFG implementation does not require any java changes and can just include content either plain or dynamic right in the template, which results in more flexible and faster implementation of storefront changes and theme development in general.
...