Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you extend the default behavior of Tridion.Cme.Commands.Open.prototype._execute()?

I have written a GUI extension which adds an additional tab to many of the Item views in the SDL Tridion CME (e.g. Component, Page and Schema etc.). I have also written some JavaScript which loads that tab directly if when the view is loaded with a tab name is specified in the URL.

The result is that if a page is loaded with the tab name added as follows:

http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64&tab=InfoTab

Rather than the default of

http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64

The Info Tab will be loaded on top, instead of the General Tab. This is performed with the following code snippet and works very well:

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

// This callback is called when any view has finished loading
function onDisplayStarted() {

    $evt.removeEventHandler($display, "start", onDisplayStarted);
    var tabname = $url.getHashParam("tab");
    if (tabname != '') {
        var tabControl = $controls.getControl($("#MasterTabControl"), "Tridion.Controls.TabControl");
        tabControl.selectItem(tabname);        
    }
}

Now I would like to make a context menu item to open items and link to the tabs using my new functionality. My first thought was to construct the Item URL myself and simply open a new window in my execute method. So I looked at the default functionality in the standard Open.prototype_execute() functionality of the GUI. This is stored in the navigation.js file of the CME, and is performed by the Tridion.Cme.Commands.Open.prototype._execute method. The code is a lot more complicated than I had anticipated as it deals with shared items, and permissions etc.

Rather than just copying all of this code to my own function, I was wondering if there is a way to elegantly extend the existing Open.prototype_execute() function and append my “&tab=MyTab” to the $cme.Popups.OPEN_ITEM_OPTIONS.URL constant for my own functions.

Any advice would be greatly appreciated.

like image 882
Chris Summers Avatar asked Oct 18 '12 14:10

Chris Summers


1 Answers

At the end the Open command uses $config.getEditorUrl(item_type) to get the url for the item view (item_type - $const.ItemType.COMPONENT, etc). There are no extension points for this part of the functionality, but you could always try to overwrite it on your own risk.

like image 125
Boris Ponomarenko Avatar answered Oct 18 '22 09:10

Boris Ponomarenko