Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending the current publishing/unpublishing screen

I have a requirement where I need to show a an alert/popup when an editor clicks on the Unpublish menu command. I will show the popup with an Yes/No Button, if Yes is selected we proceed and show the existing UnPub screen. If No is selected No activity happens and the user return back to the screen.

  1. How this can be achieved ?

  2. Can we extend/override the existing CME command's without creating a new Command for ourselves?

like image 380
bukubapi Avatar asked Feb 21 '23 00:02

bukubapi


1 Answers

I just learned how to do this yesterday (Thank to Nuno Linhares) - you need to be familiar with making a new Editor for the GUI first.

Next step is to find the name of the command that you want to overwrite (Probably "UnPublish" in your case). The easiest way to do that is to use "inspect element" with Chrome or FieFox in the GUI, and look for something like c:command="UnPublish" on the button you wish to extend.

Once you have a basic editor set up, you need to add your new command to overwrite your existing one something like this:

<extensions>
    <ext:dataextenders />
    <ext:editorextensions>
      <ext:editorextension target="CME">
        <ext:editurls />
        <ext:listdefinitions />
        <ext:taskbars />
        <ext:commands />
        <ext:commandextensions>
          <ext:commands>
            <ext:command name="UnPublish" extendingcommand="CustomUnPublishCommand"/>
          </ext:commands>
          <ext:dependencies>
            <cfg:dependency>CustomUnPublish.CommandSet</cfg:dependency>
          </ext:dependencies>
        </ext:commandextensions>
        <ext:contextmenus />
        <ext:lists />
        <ext:tabpages />
        <ext:toolbars />
        <ext:ribbontoolbars />
      </ext:editorextension>
    </ext:editorextensions>
  </extensions>

Add all your dependencies (JS and CSS etc) and command references in the normal way.

Then write your JS execute function as you would any other GUI command, and call the existing command after you have worked on your popup, something like this:

CustomUnPublish.prototype._execute = function CustomUnPublish$_execute(selection, pipeline) {
    //Insert some logic to make a popup and confirm
        blnOkToProceed = true;
    //

    if (blnOkToProceed) {

        //EDIT: Original code
        $cme.getCommand("UnPublish")._execute(selection, pipeline);
        //EDIT: Or using the suggestion from @Peter below
        $commands.executeCommand("UnPublish", selection, pipeline);
        //End Edit
    }
    return;
};
like image 127
Chris Summers Avatar answered Mar 31 '23 13:03

Chris Summers