Hello,
I'm trying to extend the comments component (resourceSuperType="social/commons/components/hbs/comments"). I want to limit the comments number to 1 per user in a comment system.
I managed to get it running and altered the HBS script to my needs, but neither can I find a HBS template property which tells me if the current user already wrote a comment, nor will the system allow me to register new HBS helpers or HBS attributes.
For the helper I tried to add a simple conditional helper. It shows up in Firebug under the Handlebars helpers, but the HBS script won't find it:
[img]handlebars helper.png[/img]
I also tried to add a custom attribute in the component's javascript found under: /libs/social/commons/components/hbs/comments/clientlibs/commentsystem.js
[img]handlebars attribute.png[/img]
My console.log output shows up in the console but the HBS script cannot find the attribute:
[img]handlebars attribute 2.png[/img]
How can you add new HBS template helpers?
Solved! Go to Solution.
Views
Replies
Total Likes
I learnt the solution to how to extend hbs script of the SCF components. Since the logic is processed on the server side (instead of the client side), the extended component's factory service (com.adobe.cq.social.commons.comments.api) needs to be extended in Java.
Example:
@Component(name = "My News Comment System Component Factory") @Service public classNewsCommentSystemComponentFactory extends CommentSystemSocialComponentFactory
Also the component created by the factory needs to be extended and here you can add your custom changes.
Example:
public class NewsCommentSystemComponent extends AbstractCommentCollection { ... public boolean isDisplayEmailCheckbox() { return this.hasUserCommented() || this.isCommentCreator(); } }
Views
Replies
Total Likes
I learnt the solution to how to extend hbs script of the SCF components. Since the logic is processed on the server side (instead of the client side), the extended component's factory service (com.adobe.cq.social.commons.comments.api) needs to be extended in Java.
Example:
@Component(name = "My News Comment System Component Factory") @Service public classNewsCommentSystemComponentFactory extends CommentSystemSocialComponentFactory
Also the component created by the factory needs to be extended and here you can add your custom changes.
Example:
public class NewsCommentSystemComponent extends AbstractCommentCollection { ... public boolean isDisplayEmailCheckbox() { return this.hasUserCommented() || this.isCommentCreator(); } }
Views
Replies
Total Likes
There is now documentation on Custom SCF Helpers.
- JK
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies