3

Is there any way to add a Component Presentation into a Page with Anguilla JavaScript?

I've seen this code in the view InsertComponentPresentation.js (WebUI\Editors\CME\Views\Popups\InsertComponentPresentation\InsertComponentPresentation.js), so I thought to use something similar:

this.fireEvent("insert", {
        components: components,
        template: templateId
    });

It's possible the problem is that I want to execute this code in a new self popup tool and maybe without the appropiate context.

Thanks in advance!

1 Answer 1

4

The following code is a snippet that I made for a colleague to quickly insert the same Component Presentation in multiple opened Pages while the Component Presentation tab is opened:

var component = "tcm:111-22222";
var template = "tcm:111-333-32";
var position = 0;
var controls = $display.getView().properties.controls;
var tab = controls.TabControl.getSelectedItem();
var list = tab.getListComponentPresentations();
list.insertItems(0, [component], template);

If you want to insert a Component Presentation from your custom popup, your popup should send the information through an event (like in your example) and then what opened the popup, should listen to that event. This listener should be in the right context to insert the Component Presentation. Something like:

var popup = $popupManager.createExternalContentPopup(...options);
$evt.addEventHandler(popup, "insert-cp", onInsertCp);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.