Is there a way only one component allowed for a parsys??? | Community
Skip to main content
GK-007
New Participant
April 22, 2016
Solved

Is there a way only one component allowed for a parsys???

  • April 22, 2016
  • 7 replies
  • 7879 views

Hi All,

we have requirement that needs to allow only one component for parsys. Generally when we drag a component in parallel it will create one more empty parsys and can create  drag/drop another component but we do not want this behavior.

Is there a way to restrict like this??

Thanks,

Kishore

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by GK-007

kautuksahni wrote...

Hi 

Adding one more reference (Old Forum Post) :- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__xc4x-how_can_i_restrictt.html

//

Coming to original question Allowed component is part of design. Make sure to configure the property "components" as type string[] with list of all the components.As an example for geometrixx you can refer /etc/designs/geometrixx/jcr:content/contentpage/par/@components.   Another trick you can follow is http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/06/default-components-in-your-parsys.html

[1]  http://labs.sixdimensions.com/blog/2013-02-04/flexible-cq5-pages/

 

Thanks and Regards

Kautuk Sahni

 

7 replies

New Participant
March 29, 2022

Hello,

I also have the same requirement. Unfortunately the links mentioned in the correct answer are not available at the moment. Could you please help? I am using AEM 6.5.11.0

Regards

Denny

GK-007
GK-007AuthorAccepted solution
New Participant
April 27, 2016

kautuksahni wrote...

Hi 

Adding one more reference (Old Forum Post) :- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__xc4x-how_can_i_restrictt.html

//

Coming to original question Allowed component is part of design. Make sure to configure the property "components" as type string[] with list of all the components.As an example for geometrixx you can refer /etc/designs/geometrixx/jcr:content/contentpage/par/@components.   Another trick you can follow is http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/06/default-components-in-your-parsys.html

[1]  http://labs.sixdimensions.com/blog/2013-02-04/flexible-cq5-pages/

 

Thanks and Regards

Kautuk Sahni

 

GK-007
GK-007Author
New Participant
April 27, 2016

Thank You

kautuk_sahni
Employee
April 25, 2016

Hi 

Adding one more reference (Old Forum Post) :- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__xc4x-how_can_i_restrictt.html

//

Coming to original question Allowed component is part of design. Make sure to configure the property "components" as type string[] with list of all the components.As an example for geometrixx you can refer /etc/designs/geometrixx/jcr:content/contentpage/par/@components.   Another trick you can follow is http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/06/default-components-in-your-parsys.html

[1]  http://labs.sixdimensions.com/blog/2013-02-04/flexible-cq5-pages/

 

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
kautuk_sahni
Employee
April 25, 2016

Hi 

Please find below the article covering the same:-

//Limit the number of Components added in a Parsys

Touch UI:- http://experience-aem.blogspot.in/2016/01/aem-61-touch-ui-limit-the-number-of-components-added-in-parsys.html Demo | Package Install

Classic UI:- http://experience-aem.blogspot.in/2016/01/aem-61-classic-ui-limit-components-added-in-parsys.html Demo | Package Install

Set the Limit - Design Mode

 



Stored in CRX
 



Limit Exceeded Error on Component Drop or Insert - Edit Mode
 

 

Another Reference Article :- http://wcmaem.blogspot.in/2013/12/copy-parsys-component.html

//

Customization of parsys to restrict number of compnents in CQ

  1. Copy the parsys component from(/libs/foundation/components/parsys) to your poroject(/apps/<project nmae>/components/).
     2.  In the design dialog add number filed configuration to enter the number of components.
 
           Crate node noofcomp of type cq:widget under /apps/<project nmae>/components/parsys
              /design_dialog/items.
           Add the following properties
 
           xtype : numberfield
           name : noOfComp
           maxValue : 20
           fieldLabel : No of components
 
 
     3.   Create ajax.jsp and write the below logic.
           <%@page import="com.day.cq.wcm.foundation.ParagraphSystem"%>
           <%@include file="/libs/foundation/global.jsp"%>
           <%
                 ParagraphSystem parSys = ParagraphSystem.create(resource, slingRequest);
                 int totalComponents=parSys.paragraphs().size();
                 int restrictCompoNo=Integer.parseInt(currentStyle.get("noOfComp","20"));
 
                if(totalComponents >= restrictCompoNo){
                      out.println("true");
                  }else{
                            out.println("false");
                    }
               %>
 4.  You need to overlay the EditBase.js and Sidekick.js
 
          Create the following structure   /apps/cq/ui/widgets/source/widgets/wcm
 
         then copy the EditBase.js and Sidekick.js form libs . Place under /wcm /
   
         In Sidekic.js at line 4098 in set timeout method add this snippet.
 
            var parentPath=editComponent.path;
            var ajaxUrl=parentPath.substr(0,parentPath.lastIndexOf("/"))+".ajax";
            var notAllowToCreate = CQ.HTTP.eval(ajaxUrl);
           
            if(!notAllowToCreate){
                editComponent.createParagraph(definition);
 
            }else{
                CQ.Ext.Msg.show({
                                   msg: 'You reached  the maximun limit. You can set the limit in disign mode.',
                                   buttons: CQ.Ext.Msg.OK,
                                   icon: CQ.Ext.MessageBox.WARNING
                                });
 
               }
                dropTarget.editComponent.hideTarget();
 
 
         In EditBase.js at line 1181  in set timeout method add this snippet.
       
           var parentPath=e.path;
            var ajaxUrl=parentPath.substr(0,parentPath.lastIndexOf("/"))+".ajax";
            var notAllowToCreate = CQ.HTTP.eval(ajaxUrl);    
            if(!notAllowToCreate){
                e.createParagraph(definition);
 
            }else{
                CQ.Ext.Msg.show({
                    msg: 'You reached  the maximun limit. You can set the limit in disign mode.',
                    buttons: CQ.Ext.Msg.OK,
                    icon: CQ.Ext.MessageBox.WARNING
                });
               
            }
            e.dialogs[CQ.wcm.EditBase.INSERT].hide();
            e.insertDialogMask.hide();

I hope this would help you.


Thanks and Regards

Kautuk Sahni

Kautuk Sahni
New Participant
April 24, 2016

Go into design mode and edit the parsys to only allow for the single component you're referring to.

https://docs.adobe.com/docs/en/aem/6-1/author/page-authoring/default-components/designmode.html

Hemant_arora
New Participant
April 23, 2016

Hi

 

Hope the below link can help you restrict.

http://wcmaem.blogspot.in/2013/12/copy-parsys-component.html