syedkabeer
I'm new here

Content transfer from Marginal Column to Content left area

Hi

     Need to transfer the particular box from marginal column to content left area automatically.

     We should not move the box manually via right click copy and paste.

     Is that any way to write a script for that.

     Please find the attached screen shot.

     Thanks in advance.

0 Kudos
3 Replies
MichaelaReydt
Community Manager

Hello,

I think you`ll need a scipt that executes the following steps:

* create a new section in the left content area

* copy the content from the old to the new section

* delete the old section in the marginal content area

Best regards

Michaela

0 Kudos
mbergmann
Crownpeak employee

Hello,

you can also just use IDProvider#moveChild(IDProvider child, int nextSiblingIndex) to move the section.

Something like this:

//e.g. context.getElement() if you use a context menu script executed on the section to move

sectionToMove=...;

page = sectionToMove.getParent().getParent();

targetBody = page.getBodyByName("NAME_OF_BODY_TO_MOVE_THE_SECTION_TO");

//move to the LAST position in the target

targetBody.moveChild(sectionToMove, -1);

//OR: move to first position

targetBody.moveChild(sectionToMove, 0);

Remarks:

  • There will be no check if the section is allowed in the target body
  • You don't need to lock the page yourself, but nevertheless should handle the LockException that will occur if the page is currently locked by another session
  • Depending on your use case you might have to rerelease the page after the move.

Michael

0 Kudos
pavone
I'm new here

Hello,

do you need further help or did Michaela's or Michael's reply already help you? If so, it would be great if you marked the reply as "correct answer" so that other community users find the solution easily. If you have already found a solution by yourself, it would be very kind of you, if you posted it here.

Best regards 

Tim

0 Kudos