7

I want to have a custom version of the ItemSelectDialogView (The pop up when including a MultimediaLink) when it is called from a component with a preset schema.

For example: I have component X which is based on schema 'activity' and I want to include an image. I click the 'browse' button and get the ItemSelectDialogView which is customised for this particular schema id. So the ItemSelectDialogView has some buttons less because it is called from a component based on that 'activity' schema.

I have a script that runs and checks which view it is (ItemSelectDialogView) and than hides some buttons. But I now want to add a check so that I know that it is called from my 'activity' component.


I was able to solve it using the answer of Alex Klock with some adjustments. I needed to add some checks in the JavaScript file that was included when the ItemSelectDialog was loaded.

In our case we could add certain users to a group on which we checked. These users were the only ones that needed the custom popup. How to do this you can find here.

Another solution that we considered is using cookies. You use the example of johnwinter down below and create your own listener which creates a cookie and call the standard pop up. This cookie lives just a few seconds. Long enough for your popup JavaScript to get it and read it which than could be used as the condition to load the customizations.

2 Answers 2

8

You can do a little magic to customize the default ItemSelectDialog view after its loaded (assumption based on your comments with John Winter). First you'll want to create an extension group in your configuration. It should look something like:

<resources catch="true">
  <cfg:filters />
  <cfg:extensiongroups>
    <cfg:extensiongroup name="ContentBloom.Extensions.ItemSelectDialog">
      <cfg:extension target="Tridion.Web.UI.Editors.CME.Views.Popups.ItemSelectDialog">
        <cfg:insertafter>ContentBloom.Resources.ItemSelectDialog</cfg:insertafter>
      </cfg:extension>
    </cfg:extensiongroup>
  </cfg:extensiongroups>
...

The important thing to note is target attribute of the cfg:extension must be what you are trying to extend and the cfg:insertafter element must point to a resource group that you created containing your JavaScript file. For the example above, this would look like:

<cfg:groups>
  <cfg:group name="ContentBloom.Resources.ItemSelectDialog">
    <cfg:fileset>
      <cfg:file type="script">/scripts/yourCustomItemSelect.js</cfg:file>
      <cfg:file type="style">/styles/yourCustomItemSelect.css</cfg:file>
    </cfg:fileset>
  </cfg:group>
</cfg:groups>

What the above is doing is loading your custom css and js files onto the existing ItemSelectDialog view page. Once you have this, your JavaScript file can do some checks and modifications. Assuming you have jQuery as one of your resources, you could do something like:

$jq(document).ready(function (e) {
    // do your modifications and checks here...
});

Hope that helps get you on your path to default popup customization!

0
6

I've done something similar to this in the past.

Here is the code i used in my gui extension to override the default multimedia pop up button:

Extensions.ContentBloom.ComponentLinkSelect.prototype.preInit = function () {
    var context = this;

var onDisplayStart = function () {
    $evt.removeEventHandler($display, "start", onDisplayStart);

    $log.message("display controller has started");

    var fieldBuilder = $display.getView().properties.controls.fieldBuilder;

    $evt.addEventHandler(fieldBuilder, "load", function () {
        $log.message("field builder has loaded");

        var controls = $controls.controls;

        var mmLinkCollection = $controls.controls["Tridion.Controls.MultiMediaLinkControl"];

        if (mmLinkCollection) {
            for (var control in mmLinkCollection) {
                var mmLinkControl = mmLinkCollection[control];

                if (Tridion.OO.implementsInterface(mmLinkControl, "Tridion.Controls.MultiMediaLinkControl")) {


                    var browseButton = mmLinkControl.properties.controls.browseButton
                    $evt.removeAllEventHandlers(browseButton, "click");
                    (function (lc) {
                        $evt.addEventHandler(browseButton, "click", function () {
                            context.showAssetPicker(lc);
                        });
                    })(mmLinkControl);

                }

            }
        }
    });
}

$evt.addEventHandler($display, "start", onDisplayStart);

};

I think the code speaks for itself, but here's a sentence to explain it...Find the existing button responsible for opening the item selector, remove the default event on the button and simply add your own event for the onclick

1
  • Thanks for the answer. I think I understand what you are trying to do in your code. Instead of using the default Popup you can launch a custom popup. The thing is I would want the default popup to load, but once loaded I want to change the layout with some modifications. Making a complete custom popup would take to much time. Commented Aug 4, 2014 at 8:09

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.