How to configure the SDL Tridion CME extension for a subset of views?

I created a new editor for the SDL Tridion, which adds some new features to the ribbon bar. This can be enabled by adding the following snippet to editor.config

<!-- ItemCommenting PowerTool --> <ext:extension assignid="ItemCommenting" name="Save and&lt;br/&gt;Comment" pageid="HomePage" groupid="ManageGroup" insertbefore="SaveCloseBtn"> <ext:command>PT_ItemCommenting</ext:command> <ext:title>Save and Comment</ext:title> <ext:issmallbutton>false</ext:issmallbutton> <ext:dependencies> <cfg:dependency>PowerTools.Commands</cfg:dependency> </ext:dependencies> <ext:apply> <ext:view name="*" /> </ext:apply> </ext:extension> 

This applies to all views using the wildcard value in node. This leads to the fact that my new button is added to the ribbon of every kind, including the main panel. Is there a way to add this to all views except the control panel? Or do I need to create something like this?

  <ext:apply> <ext:view name="PageView" /> <ext:view name="ComponentView" /> <ext:view name="SchemaView" /> </ext:apply> 

If this is the only way to achieve the desired result, is there a list of all view names somewhere?

+8
tridion tridion-2011
source share
2 answers

The workaround provided by Jaime will not work because:

  • The ribbon toolbar will hide the buttons only on the Create tab if the isAvailable method of the corresponding command returns false.
  • Most of the buttons in RibbonToolbar implement the specific Tridion.Controls.RibbonButton interface. This means that when you try to get Tridion.Controls.Button control for the same element - you get a completely different control based on the same html element. So RibbonToolbar will not know about it, and it will not work correctly.
  • If you want to hide the button in RibbonToolbar, you should use the public methods on RibbonToolbar and RibbonPage instead. Thus, it will be correctly processed by RibbonToolbar. Example:
 var toolbar = $controls.getControl($("#ItemToolbar"), "Tridion.Controls.RibbonToolbar"); var page = toolbar.getPageById("HomePage"); page.hideItem(buttonId); page.showItem(buttonId); 

As for the original question, here is a pretty simple and simple solution:

 <ext:add> <ext:extension assignid="ItemCommenting" name="Save and&lt;br/&gt;Comment" pageid="HomePage" groupid="ManageGroup" insertbefore="SaveCloseBtn"> <ext:command>PT_ItemCommenting</ext:command> <ext:title>Save and Comment</ext:title> <ext:issmallbutton>false</ext:issmallbutton> <ext:dependencies> <cfg:dependency>PowerTools.Commands</cfg:dependency> </ext:dependencies> <ext:apply> <ext:view name="*" /> </ext:apply> </ext:extension> </ext:add> <ext:remove> <ext:extension id="ItemCommenting"> <ext:apply> <ext:view name="DashboardView" /> </ext:apply> </ext:extension> </ext:remove> 
+8
source share

As far as I know, you need to specify all views or use a wildcard. It will be nice that the isAvailable function will work for the Ribbon Toolbar buttons, right? This means that if the command returns false in the _isAvailable method, the button will not be displayed ...

Ok, I found a job. You can do something like this in your isAvailable method in your command:

 Your.Namespace.PT_ItemCommenting.prototype._isAvailable = function PT_ItemCommenting$_isAvailable(selection) { var isAvailable = $display.getView().getId()!='DashboardView'; if(isAvailable){ return true; } var button = $controls.getControl($("#ItemCommenting"), "Tridion.Controls.Button"); button.hide(); return false; }; 

I think this is actually a good practice, as it will β€œhide” teams if they are not available, right?

Let me know how it works.

+2
source share

All Articles