How to limit how many components can be dropped into an iparsys | Community
Skip to main content
LinearGradient
Level 6
October 16, 2015
Solved

How to limit how many components can be dropped into an iparsys

  • October 16, 2015
  • 2 replies
  • 1423 views

In a page template I have a parsys in which a header component can be dropped. Something similar to this:

<cq:include path="parsys-header" resourceType="foundation/components/iparsys"/>

How can I configure this iparsys so that when it is empty, the header component can be dropped into it but when the header component is already dropped into it, nothing else can be dropped into it?

Thanks.

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 Sam205505050

Follow the below steps: 

Step1: Overlay parsys under apps/urproject
Step2: create a widget called "totalcomp" under desing_dialog/items/title/ and add property maxValue =10
Step3: create a file comp.jsp under apps/urproject/components/parsys and check the total size of ParagraphSystem using
int totalComponents=parSys.paragraphs().size();
int restrictCompoNo=Integer.parseInt(currentStyle.get("totalcomp","10"));
Step 4: Overlay Sidekick.js under ur apps/
Step 5: in notifyDropDT method add the below code to check 
var checkUrl=parentPath.substr(0,parentPath.lastIndexOf("/"))+".comp";
var canCreate = CQ.HTTP.eval(checkUrl); 
Step 6: if canCreate is true then call editComponent.createParagraph(definition);

2 replies

smacdonald2008
Level 10
October 16, 2015

Here is a StackOverFlow thread (not the exact use case) - but related and points you in the right direction:

http://stackoverflow.com/questions/19051288/placing-default-components-in-an-iparsys

Sam205505050Accepted solution
Level 6
October 16, 2015

Follow the below steps: 

Step1: Overlay parsys under apps/urproject
Step2: create a widget called "totalcomp" under desing_dialog/items/title/ and add property maxValue =10
Step3: create a file comp.jsp under apps/urproject/components/parsys and check the total size of ParagraphSystem using
int totalComponents=parSys.paragraphs().size();
int restrictCompoNo=Integer.parseInt(currentStyle.get("totalcomp","10"));
Step 4: Overlay Sidekick.js under ur apps/
Step 5: in notifyDropDT method add the below code to check 
var checkUrl=parentPath.substr(0,parentPath.lastIndexOf("/"))+".comp";
var canCreate = CQ.HTTP.eval(checkUrl); 
Step 6: if canCreate is true then call editComponent.createParagraph(definition);