Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you create a context menu item that links to a specific tab in the SDL Tridion CME?

I would like to add an item to the context menu using a GUI extension which links directly to a tab in a view.

A good example was in an older version of SDL Tridion. There was a link to the "Info" tab for components in the context menu which opened the component view directly on the "info" tab.

Is it possible to recreate this, and if so are there any samples on how to link to a specific tab?

I tried adding the following JavaScript to my tab.js:

var tabname = $url.getHashParam("tab")
if (tabname != '') {
    if ($j('#' + tabname)) {
        $j('#' + tabname).focus();
    }
}

This code fires correctly, except the tab never gets selected. Is there a method which actually selects the tab?

like image 670
Chris Summers Avatar asked Oct 10 '12 12:10

Chris Summers


1 Answers

I'd say you'd need to write two parts:

  1. the command opens the popup needs to pass a parameter to the popup that indicates the tab to focus
  2. in the popup you need some JavaScript that recognizes/parses the parameter and then focuses the correct tab

I think there are quite some examples of passing parameters from a command to its popup already, so will focus on #2.

Selecting a tab in a popup

When you see tabs in a Tridion GUI, they are typically part of a Tridion.Controls.TabControl. If you have JavaScript that runs within your popup, you can get all tab controls with this snippet:

var tab = $controls.getControl($("#MasterTabControl"), 
                               "Tridion.Controls.TabControl");

Then we just need to select the correct tab on it:

tab.selectItem('InfoTab');

Where InfoTab is the tab we want to focus and thus the parameter you're passing into the popup.

like image 73
Frank van Puffelen Avatar answered Sep 28 '22 18:09

Frank van Puffelen