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\cartridge\import\templates\HelloWorld
.Type or copy the following into the contents of the file:
<ContentTemplate xmlns="http://endeca.com/schema/content-template/2008" xmlns:editors="editors" type="SecondaryContent"> <Description>A sample cartridge that can display a simple message.</Description> <ThumbnailUrl>/ifcr/tools/xmgr/img/template_thumbnails/sidebar_content.jpg</ThumbnailUrl> <ContentItem> <Name>Hello cartridge</Name> <Property name="message"> <String/> </Property> <Property name="messageColor"> <String/> </Property> </ContentItem> <EditorPanel> <BasicContentItemEditor> <editors:StringEditor propertyName="message" label="Message"/> <editors:StringEditor propertyName="messageColor" label="Color"/> </BasicContentItemEditor> </EditorPanel> </ContentTemplate>
Save the file with the name
template.xml
in theHelloWorld
directory of your Discover Electronics application, for example:C:\Endeca\apps\Discover\config\cartridge_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
. The default Username isadmin
and the default Password isadmin
.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 in the bottom left.
The cartridge selector dialog displays.
Select the new Hello cartridge from the Content Tree on the left and configure it as shown:
Try to view the cartridge in the Discover Electronics application.
In a Web browser, navigate to
http://<workbench-host>:8006/discover-authoring/
.The error displays because we have not yet created a renderer for the Hello cartridge.
Scroll down to the bottom of the page and click the json link to view the serialized Assembler response model that represents the current page.
Oracle recommends that you use a browser or install a plugin that supports native JSON display. Otherwise, you can download the JSON response as a file.
Alternatively, you can click the xml link to view the same response in XML. In this guide, we use the JSON format when examining the Assembler response.
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.
{
"@type": "ResultsPageSlot",
"name": "Browse Page",
"contentCollection": "Search And Navigation Pages",
"ruleLimit": "1",
"contents": [
{
"@type": "ThreeColumnNavigationPage",
"name": "Default Page",
"title": "Discover Electronics",
"metaKeywords": "camera cameras electronics",
"metaDescription": "Endeca eBusiness reference application.",
"links": [ ],
"header": [ … ],
"leftColumn": [ … ],
"main": [ … ],
"rightColumn": [
{ … },
{ … },
{
"@type": "Hello",
"name": "Hello cartridge",
"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.