The example of extending components uses the comment system, which is actually composed of two components
Both components needs to be put in place, especially if customizing the appearance of a posted comment.
Only one comment system per site page is allowed.
Many Communities features already include a comment system whose resourceType can be modified to reference the extended comment system.
These directions specify a Group value other than .hidden
so the component may be made available from the component browser (sidekick).
The deletion of the auto-created JSP file is because the default HBS file will be used instead.
Browse to CRXDE|Lite (http://localhost:4502/crx/de/index.jsp)
Create a location for custom applications:
Select the /apps
node
Select the /apps/custom
node
Select the /apps/custom/components
node
Create > Component…
Select Next
Select Next
Select Next
Select OK
Expand the node just created: /apps/custom/components/comments
Select Save All
Right-click comments.jsp
Select Delete
Select Save All
These directions set Group to .hidden
as only the parent component should be included within a page.
The deletion of the auto-created JSP file is because the default HBS file will be used instead.
Navigate to the /apps/custom/components/comments
node
Right-click the node
Select Create > Component…
*.hidden*
Select Next
Select Next
Select Next
Select OK
Expand the node just created: /apps/custom/components/comments/comment
Select Save All
Right-click comment.jsp
Select Delete
Select Save All
Using CRXDE Lite:
Copy comments.hbs
Edit comments.hbs
to:
Change the value of the data-scf-component
attribute (~line 20):
social/commons/components/hbs/comments
/apps/custom/components/comments
Modify to include the custom comment component (~line 75):
{{include this resourceType='social/commons/components/hbs/comments/comment'}}
{{include this resourceType='/apps/custom/components/comments/comment'}}
Copy comment.hbs
Edit comment.hbs
to:
Change the value of the data-scf-component attribute (~ line 19)
social/commons/components/hbs/comments/comment
/apps/custom/components/comments/comment
Select /apps/custom
node
Select Save All
To avoid having to explicitly include this client library, the categories value for the default comment system’s clientlib could be used ( cq.social.author.hbs.comments
), but then this clientlib would be included for all instances of the default component as well.
Using CRXDE Lite:
Select /apps/custom/components/comments
node
Select Create Node
Name: clientlibs
Type: cq:ClientLibraryFolder
Add to Properties tab:
categories
Type String
Value cq.social.author.hbs.comments
Multi
dependencies
Type String
Value cq.social.scf
Multi
Select Save All
With /apps/custom/components/comments/clientlib
s node selected, create 3 files:
css.txt
js.txt
Enter ‘customcommentsystem.js’ as the content of js.txt
Select Save All
When extending (overriding) an SCF component, the resourceType is different (overlaying makes use of the relative search mechanism that searches through /apps
before /libs
so that the resourceType remains the same). This is why it is necessary to write JavaScript (in the client library) to register the SCF JS model and view for the custom resourceType.
Enter the following text as the content of customcommentsystem.js
:
(function($CQ, _, Backbone, SCF) {
"use strict";
var CustomComment = SCF.Components["social/commons/components/hbs/comments/comment"].Model;
var CustomCommentView = SCF.Components["social/commons/components/hbs/comments/comment"].View;
var CustomCommentSystem = SCF.Components["social/commons/components/hbs/comments"].Model;
var CustomCommentSystemView = SCF.Components["social/commons/components/hbs/comments"].View;
SCF.registerComponent('/apps/custom/components/comments/comment', CustomComment, CustomCommentView);
SCF.registerComponent('/apps/custom/components/comments', CustomCommentSystem, CustomCommentSystemView);
})($CQ, _, Backbone, SCF);
In order to experience the extended component in the publish environment, it is necessary to replicate the custom component.
One way to do so is:
From global navigation,
Start Path
to /apps/custom