Expand my Community achievements bar.

SOLVED

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

Avatar

Level 9

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

1 Accepted Solution

Avatar

Correct answer by
Level 9

kautuksahni wrote...

Hi 

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

//

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...

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

 

Thanks and Regards

Kautuk Sahni

 

View solution in original post

7 Replies

Avatar

Level 8

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

Avatar

Administrator

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-pa... 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

Avatar

Administrator

Hi 

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

//

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...

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

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Correct answer by
Level 9

kautuksahni wrote...

Hi 

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

//

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...

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

 

Thanks and Regards

Kautuk Sahni

 

Avatar

Level 3

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