This section describes how to define a new cartridge and use Workbench to configure it to appear on a page.
To create and configure a basic "Hello, World" cartridge, follow these steps:
Navigate to the templates directory of your application, and create a subdirectory named "HelloWorld." This directory name is the template ID for your template.
For example:
C:\Endeca\apps\Discover\config\import\templates\HelloWorld
.Create a cartridge template JSON file.
Type or copy the following into the contents of the file:
{ "ecr:type": "template", "@group": "SecondaryContent", "@description": "A sample cartridge that can display a simple message", "@thumbnailUrl": "thumbnail.jpg", "defaultContentItem": { "@name": "Hello cartridge", "message": "", "messageColor": "" }, "editorPanel": { "editor": "editors/DefaultEditorPanel", "children": [ { "editor": "GroupLabel", "label": "${group.contents.label}" }, { "editor": "editors/StringEditor", "propertyName": "message", "label": "Message" }, { "editor": "editors/StringEditor", "propertyName": "messageColor", "label": "Color" } ] }, "typeInfo": { "message": {"@propertyType": "String"}, "messageColor": {"@propertyType": "String"} } }
Save the file with the name
_.json
in theHelloWorld
directory of your Discover Electronics application, for example:C:\Endeca\apps\Discover\config\import\templates\HelloWorld
.
Upload the template to Workbench.
Open a command prompt and navigate to the
control
directory of your deployed application, for example,C:\Endeca\apps\Discover\control
.Run the
set_templates
command.C:\Endeca\apps\Discover\control>set_templates.bat Removing existing cartridge templates for Discover Setting new cartridge templates for Discover Finished setting templates C:\Endeca\apps\Discover\control>
Open Workbench in a Web browser.
The default URL for Workbench is
http://<workbench-host>:8006
.In the tree on the left, select Search and Navigation Pages under the Content section, then select the Default Page.
In the Edit Pane on the right, select the right column section from the Content Tree.
The cartridge selector dialog displays.
Select the new Hello cartridge from the Content Tree on the left and configure the color as #FF00000.
Try to view the cartridge in the Discover Electronics application.
The following shows the JSON representation of the page with most of the tree collapsed, highlighting the data for the cartridge that we just added.
{
"workflowState": "ACTIVE",
"ecr:lastModifiedBy": "admin",
"ecr:lastModified": "2016-09-12T13:38:32.258+05:30",
"priority": 100,
"ecr:createDate": "2016-09-12T13:38:32.258+05:30",
"ecr:type": "content-item",
"contentItem": {
"@name": "Three-Column Page",
"metaKeywords": "camera cameras electronics",
"@type": "ThreeColumnPage",
"title": "Discover Electronics",
"metaDescription": "Oracle Commerce reference application.",
"redirectGroup": "",
"headerContent":{...},
"leftContent": {...},
"mainContent": {...},
"rightContent":[
{ … },
{ … },
{
"@name": "Hello World",
"@type": "HelloWorld",
"message": "Hello, World",
"messageColor": "#FF0000"
}
]
}
],
…
}
In the next section, we'll create a simple renderer that displays the message based on the values configured in Experience Manager.