锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
a. 鍦?/span>CRXDE Lite閲岋紝鍙抽敭鐐瑰嚮鐩稿簲鐨勭粍浠舵枃浠跺す濡?/span>/apps/demoNoah/components錛屽茍涓旈夋嫨“Create”—“Create component…”,鍦ㄥ脊鍑虹殑紿楀彛涓緭鍏ョ浉搴斾俊鎭紝濡備笅鍥撅細
b. 涓璺偣鍑?#8220;Next”鐩村埌“OK”銆?/p>
2. 鍒涘緩瀵硅瘽妗?/span> a. 鍙抽敭鐐瑰嚮鍒氭墠寤虹珛鐨勭粍浠訛紝閫夋嫨“Create”—“Create Dialog…”鍦ㄥ脊鍑虹殑紿楀彛涓緭鍏ョ浉搴斾俊鎭紝濡備笅鍥撅細
b. 鐐瑰嚮淇濆瓨錛屾鏃剁洰褰曠粨鏋勫涓嬶細
d. 鐢ㄥ悓鏍風殑鏂規硶鍦?#8220;items”涓嬪緩绔?#8220;title”鑺傜偣錛屼絾姝ゆ椂Type閫夋嫨“cq:Widget”
e. 鐒跺悗錛屾坊鍔犲涓嬪睘鎬э細
f. 鐒跺悗錛屽啀鍦?#8220;title”涓嬪緩绔?#8220;fieldConfig”鑺傜偣錛屽睘鎬у涓嬶細
g. 鐢ㄥ悓鏍鋒柟娉曞緩绔?#8220;des”鑺傜偣錛屾敞鎰忕洰褰曠粨鏋勶紝濡傚浘
3. 鑾峰彇鍙橀噺鍊?/span>
a. 鎵撳紑“Buick_Tech_Info.jsp”,杈撳叆濡備笅鍐呭錛?/span>
b. 榪欓噷鍙富瑕佽鏄庣殑鏄庝箞鑾峰彇鐢ㄦ埛杈撳叆鐨勬暟鎹紝鍏蜂綋鎯蟲庝箞鏄劇ず鍙嚜琛屽疄鐜幫紝姣斿錛?/span>
4. 鍦ㄩ〉闈腑娣誨姞涓婄浉搴旂殑緇勪歡
a. 鍒伴〉闈腑鎵懼埌榪欎釜緇勪歡錛屽茍鎷栦竴涓埌欏甸潰涓?/span>
b. 鍦ㄨ繖涓尯鍩熶腑鐐瑰彸閿紝閫夋嫨“Edit”銆備細鍑虹幇綾諱技濡備笅鐣岄潰
b. 濉啓瀹屾垚鍚庯紝鐐?#8220;OK”錛岀敤鎴鋒墍濉啓鐨勪俊鎭細鏄劇ず鍦ㄩ〉闈笂銆?/span>
5. 鍒版鏁翠釜榪囩▼瀹屾垚銆?/span>
A quick way to get started is to copy an existing component and then make the changes you want. You can also use this method to edit existing components (although Day recommends that you back up the original component).
An example of how to develop a component is described in detail in Extending the Text and Image Component - An Example.
To develop new components for CQ WCM based on existing component, you copy the component and create a javascript file for the new component and store it in a location accessible to CQ5:
Create a new component folder in /apps/
<website-name>
/components/
by copying an existing component, such as the Text component, and renaming it.<MyComponent>
In the CRX Explorer, modify the jcr:description
and jcr:title
to reflect its new name.
Open the new component folder and make the changes you require; also, delete any extraneous information in the folder.
You can make changes such as:
adding a new field in the dialog box
replacing the .jsp
file (name it after your new component)
or completely reworking the entire component if you want
For example, if you take a copy of the standard Text component, you can add an additional field to the dialog box, then update the .jsp
to process the input made there.
In the Content Explorer, navigate to the component and change the allowedParents
property to */parsys
, which makes it available to the paragraph system.
![]() |
Note |
---|---|
Either cq:editConfig node, dialog, or design_dialog node should be present and properly initialized for the new component to appear. |
Activate the new component in your paragraph system either by adding /apps/
to the <website-name>
/components/<MyComponent>
/etc/designs/default/<website-name>/jcr:content/contentpage/parsys/components
property in CRX or by following the instructions in Adding new components to paragraph systems.
In CQ WCM, open a page in your web site and insert a new paragraph of the type you just created to make sure the component is working properly.
![]() |
Note |
---|---|
To see timing statistics for page loading, you can use |
After the component has been developed, you add it to the paragraph system, which enables authors to select and use the component when editing a page.
Access a page within your authoring environment that uses the paragraph system; for example <
.contentPath
>/Test.html
Switch to Design mode by either:
adding ?cmsmode=design
to the end of the URL and accessing again; for example <contextPath>/ Test.html?cmsmode=design
.
clicking Design
in Sidekick
You are now in designmode and can edit the paragraph system:
Click Edit
.
A list of components belonging to the paragraph system are shown (all those defined with the property allowedParents=*/parsys
). Your new component is also listed.
The components can be activated (or deactivated) to determine which are offered to the author when editing a page.
Activate your component, then return to normal edit mode to confirm that it is available for use.
This section provides an example on how to extend the widely used text and image standard component with a configurable image placement feature.
The extension to the text and image component allows editors to use all the existing functionality of the component plus have an extra option to specify the placement of the image either:
on the left-hand side of the text (current behavior and the new default)
as well as on the right-hand side
After extending this component, you can configure the image placement through the component's dialog box.
The following techniques are described in this exercise:
Copying existing component node and modifying its metadata
Modifying the component's dialog, including inheritance of widgets from parent dialog boxes
Modifying the component's script to implement the new functionality
To create the new component, we use the standard textimage
component as a basis and modify it. We store the new component in the Geometrixx CQ WCM example application. To extend the textimage component, go to the CRX Explorer (
and log in as server name:port number
/crx)admin
and then navigate to the Content Explorer.
Copy the standard textimage component from /libs/foundation/components/textimage
into the Geometrixx component folder, /apps/geometrixx/components
, using textimage
as the target node name. (Copy the component by navigating to the component, right-clicking and selecting Copy
and browsing to the target directory.)
To keep this example simple, navigate to the component you copied and delete all the subnodes of the new textimage node except
for the following ones:
dialog definition: textimage/dialog
component script: textimage/textimage.jsp
Edit the component metadata:
Component name
Set jcr:description
to Text Image Component (Extended)
Set jcr:title
to Text Image (Extended)
Component listing in the paragraph (parsys component) system (leave as is)
Leave allowedParents
defined as */parsys
Group, where the component is listed in the sidekick (leave as is)
Leave componentGroup
set to General
Parent component for the new component (the standard textimage
component)
Set sling:resourceSuperType
to foundation/components/textimage
After these steps the component node looks like the following:
Modify the component's dialog box to include the new option. The new component inherits the parts of the dialog box that are the same as in the original. The only addition we make is to extend the Advanced
tab, adding an Image Position
dropdown list, with options Left
and Right
:
Leave the textimage/dialog
properties unchanged.
Note how textimage/dialog/items
has three subnodes, tab1
to tab3
, representing the three tabs of the textimage
dialog box.
For the first two tabs (tab1
and tab2
):
Change xtype
to cqinclude
(to inherit from the standard component).
Add a pathParameter
property with values /libs/foundation/components/textimage/dialog/items/tab1.infinity.json
and /libs/foundation/components/textimage/dialog/items/tab2.infinity.json
, respectively.
Remove all other properties or subnodes.
For tab3
:
Leave the properties and subnodes without changes
Add a new field definition to tab3/items
, node position
of type cq:Widget
Set the following properties (of type String
) for the new tab3/items/position
node
name
: ./imagePosition
xtype
: selection
fieldLabel
: Image Position
type
: select
Add subnode position/options
of type cq:WidgetCollection
to represent the two choices for image placement, and under it create two nodes, o1
and o2
of type nt:unstructured
For node position/options/o1
set the properties: text
to Left
and value
to left
For node position/options/o2
set the properties: text
to Right
and value
to right
Image position is persisted in content as the imagePosition
property of the node representing textimage
paragraph.
After these steps, the component dialog box looks like this:
Extend the component script, textimage.jsp
, with extra handling of the new parameter.
Open the /apps/geometrixx/components/textimage/textimage.jsp
script for editing.
We are going to manipulate the style of the <div class="image">
tag, generated by the component, to float the image to the right. It is located in the following area of the code:
Image img = new Image(resource, "image");
if (img.hasContent() || WCMMode.fromRequest(request) == WCMMode.EDIT) {
%><div class="image"><%
img.loadStyleData(currentStyle);
We are going to replace the emphasized code fragment %><div class="image"><%
with new code generating a custom style for this tag.
Copy the following code fragment, and replace the %><div class="image"><%
line with it:
// todo: add new CSS class for the 'right image' instead of using // the style attribute String style=""; if (properties.get("imagePosition", "left").equals("right")) { style = "style=\"float:right\""; } %><div <%= style %> class="image"><%
Note that for simplicity we are hard-coding the style to the HTML tag. The proper way to do it would be to add a new CSS class to the application styles and just add the class to the tag in the code in the case of a right-aligned image.
The code fragment, after the change, should look like this (new code emphasized):
Image img = new Image(resource, "image");
if (img.hasContent() || WCMMode.fromRequest(request) == WCMMode.EDIT) {
// todo: add new CSS class for the 'right image' instead of using
// the style attribute
String style="";
if (properties.get("imagePosition", "left").equals("right")) {
style = "style=\"float:right\"";
}
%><div <%= style %> class="image"><%
img.loadStyleData(currentStyle);
Save the script to the repository.
The component is ready to test.
After the component has been developed, you can add it to the paragraph system, which enables authors to select and use the component when editing a page. These steps allow you to test the component.
Open a page in Geometrixx; for example, English
/Company
Switch to design mode by clicking Design
in Sidekick
Edit the paragraph system design by clicking Edit
on the paragraph system in the middle of the page. A list of components, which can be placed in the paragraph system are shown, and it should include your newly developed component, Text Image (Extended)
. Activate it for the paragraph system by selecting it and clicking OK
.
Switch back to the editing mode.
Add the Text Image (Extended) paragraph to the paragraph system, initialize text and image with sample content. Save and you should see the default rendering of Text and Image component:
Open the dialog of the text and image paragraph, and change the Image Position
on the Advanced
tab to Right
, and click OK
to save the changes.
You see the paragraph rendered with the image on the right:
The component is now ready to use.
The component stores its content in a paragraph on the Company page. The following screenshot shows how our new configuration parameter is persisted in the repository, with the node representing the paragraph we have just created.
The textimage/imagePosition
parameter represents the position of the image for this paragraph on /content/geometrixx/en/company
page.
Needless to say a new template can be created completely from scratch, but often an existing template will be copied and updated to save you time and effort. For example, the templates within Geometrixx can be used to get you started.
Copy an existing template (preferably with a definition as close as possible to what you want to achieve) to a new node.
![]() |
Note |
---|---|
Templates are usually stored in |
Change the jcr:title of the new template node to reflect its new role. You can also update the jcr:description if appropriate.
Copy the component on which the template is based (this is indicated by the sling:resourceType property of the jcr:content node within the template) to create a new instance.
![]() |
Note |
---|---|
Components are usually stored in |
Update the jcr:title and jcr:description of the new component.
Replace the thumbnail.png
if you want a new thumbnail picture to be shown in the template selection list.
Update the sling:resourceType of the template's jcr:content node to reference the new component.
Make any further changes to the functionality or design of the template and/or its underlying component.
Changes made to the /apps/
node will affect the template instance (as in the selection list).<website>
/templates/<template-name
>
Changes made to the /apps/<
node will affect the content page created when the template is used.website
>/components/<component-name
>
You can now create a page within your website using the new template.