I have created a new editor for SDL Tridion which adds some new functionality to the ribbon bar. This is enabled by adding the following snippet to the editor.config
<!-- ItemCommenting PowerTool -->
<ext:extension assignid="ItemCommenting" name="Save and<br/>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 is applied to all views by using a wildcard value in the node. This has results in my new button being added to the ribbon of every view, including the main dashboard. Is there a way to add this to all views except for the dashboard? Or do I have 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 result I need, is there a list of all the view names somewhere?
Workaround provided by Jaime will not gonna work, because:
isAvailable
method of the corresponding command will return false.Tridion.Controls.RibbonButton
interface. This means, when you'll try
to get Tridion.Controls.Button
control for the same element - you'll
get totally different control, based on the same html element. So
RibbonToolbar will not know about it and it will work incorrectly.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 pretty simple and easiest solution:
<ext:add>
<ext:extension assignid="ItemCommenting" name="Save and<br/>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>
As far as I know you need to specify all the views or use the wildcard. It will be nice that the isAvailable functionality would work for the Ribbon Tool bar buttons, right? Meaning that if the command returns false in the _isAvailable method, the button will not show...
Well, I found a work around. You can do something like this within 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, since it will "hide" the commands if they shouldn't be available, right?
Let me know how it works out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With