%@ Import Namespace="Trid" name="description" /> %@ Import Namespace="Trid" />

Creating Buttons using Usercontrol in Tridion Ribbon


I have created a usercontrol for having two buttons one below the other as

<pre class="lang-cs prettyprint-override"><%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ViewItemsGroup.ascx.cs" Inherits="SDL.Examples.UI.Controls.ViewItemsGroup" %> <%@ Import Namespace="Tridion.Web.UI" %> <c:RibbonItemsGroup runat="server" ID="RibbonItemsGroup"> <c:RibbonButton runat="server" CommandName="ViewStaging" Title="View in Staging" Label="View In Staging" IsSmallButton="true" ID="ViewStagingBtn" /> <c:RibbonButton runat="server" CommandName="ViewLive" Title="View in Live" Label="View in Live" IsSmallButton="true" ID="ViewLiveBtn" /> </c:RibbonItemsGroup>

In the extension.config i am refering to the usercontrol as shown below.

<pre class="lang-xml prettyprint-override"><ext:extension assignid="ViewItemsGroup" groupid="EditGroup" name="View" pageid="HomePage" insertbefore="PublishGroup"> <ext:group>~/Controls/ViewItemsGroup.ascx</ext:group> <ext:dependencies> <cfg:dependency>My.Theme</cfg:dependency> </ext:dependencies> <ext:apply> <ext:view name="DashboardView"> <ext:control id="DashboardToolbar" /> </ext:view> <ext:view name="PageView"> <ext:control id="ItemToolbar" /> </ext:view> </ext:apply> </ext:extension> <ol><li>

Do i need to include my button(s) details (mentioned in the usercontrol like ID) also in extension.config? Is it required to be added in <ext:command> ---- </ext:command> or any other place.

</li> <li>

The usercontrol created, I am just placing along with the extension.config, .js and refering to ascx in my extension.config file. Do i need to place my usercontrol in any of the other folders?

</li> </ol>



In your extension.config, you specify the dependencies for the ItemsGroup under the ext:dependencies node. This should point towards your cfg:group where you reference a commandset which in turn points to your JavaScript files. You need to make these references correctly else the SDL Tridion UI framework won't know where to find your code. The system is just like us unable to perform magic and also does not come with a crystal ball.

</li> <li>

Same goes for the user control, if you don't place it alongside your other extension files like the configuration, JavaScript and CSS, how would the UI framework be able to find it. The location of where you placed it, you specify in the ext:group node. For example ~/Controls/MyItemsGroup.ascx then you placed it in a sub directory Controls in the root of your extension.

</li> </ol>

Your configuration should look something like this then, with the dependencies pointing to the group you have specified above it under the resources node:

<pre class="lang-xml prettyprint-override"><ext:ribbontoolbars> <ext:add> <ext:extension assignid="MyGroup" ...> <ext:group>~/Controls/MyItemsGroup.ascx</ext:group> <ext:dependencies> <cfg:dependency>My.Commands</cfg:dependency> </ext:dependencies> ... </ext:extension> </ext:add> </ext:ribbontoolbars>

Then in your control, you reference the command directly in its attributes, this is the JavaScript command under which the _isAvailable and _isEnabled methods are etc. The control will have something like:

<pre class="lang-cs prettyprint-override"><c:RibbonItemsGroup runat="server" ID="MyItemsGroup"> <c:RibbonButton runat="server" CommandName="MyBtn" Title="My Title" Label="My Label" IsSmallButton="true" ID="MyId" /> ... </c:RibbonItemsGroup>

Lastly the JavaScript which implements your button command will then use the CommandName in its namespace:

<pre class="lang-js prettyprint-override">Type.registerNamespace("Extensions"); Extensions.MyBtn = function Extensions$MyBtn() { Type.enableInterface(this, "Extensions.MyBtn"); this.addInterface("Tridion.Cme.Command", ["MyBtn"]); }; Extensions.MyBtn.prototype._isAvailable = function MyBtn$_isAvailable(selection) { return true; }; Extensions.MyBtn.prototype._isEnabled = function MyBtn$_isEnabled(selection) { return this._isAvailable(selection); }; Extensions.MyBtn.prototype._execute = function MyBtn$_execute(selection) { // this is where your code comes };


  • wldeploy on all files in deployment folder
  • AJAX: Form Submit to post comments
  • Crystal Reports MVVM Data Source
  • What is difference between 'call' and '__call__' in TensorFlow BasicLSTMCell imp
  • Outlook auto forward set replyto to orginal sender rather than forwarder
  • Adding a system dependency to Maven
  • Posting to Facebook fan page feed as user through PHP SDK
  • Correct mvn version for dispatch.databinder.net
  • Wiring multiple independent Spring Applications using Maven
  • Why Akka-Http still uses older Akka-Actor?
  • Exclude jar from war Maven 3
  • SLURM: How to view completed jobs full name?
  • Is it a good practice to use static classes to making the UI elements accessible from all the classe
  • Android: Transfering Data via ContentIntent
  • Scaladoc options with Maven
  • javax.persistence.EntityManager.getCriteriaBuilder()Ljavax/persistence/criteria/CriteriaBuilder
  • GWT-exporter. Working example
  • C3p0 with Hibernate 4.2 error: setCharacterStream(ILjava/io/Reader;J)V is abstract
  • Neo4j unmanaged extension - add custom request Filter to web server
  • How do I get the “Next available number” from an SQL Server? (Not an Identity column)
  • How to Get Maven Project Version From Java Method as Like at Pom
  • Get Distinct rows from a result of JOIN in SQL Server
  • SQL Server PIVOT Function
  • MVC 3 - Editor template for List Model [closed]
  • Maven + Surefire/Failsafe - forkMode=“perthread” is not working … a workaround?
  • Is there a way to focus on a dynamically created form on Angular 4/Ionic3?
  • Git Configuration with eclipse--not able to push code from eclipse to remote git server
  • How to set default security access for a Page Type in Silverstripe?
  • Get Users in Group from Azure AD via Microsoft Graph
  • Flask-Restful error: “as_view” method not inherited
  • Maven, ActionBarSherlock v4 and Roboguice v2 - How do I get it to build?
  • Open Graph Publish Using Spring Social
  • Visual Studio 2008 and JavaScript brackets formatting
  • How can I create one checksum of two files in Maven to use it in the name of a directory
  • composer dependency stating in doesn't have php-xsl
  • How to create two column output from a single column
  • How can I get the choice “H2” back in the H2 consol?
  • Approximate Order-Preserving Huffman Code
  • How to use JavaScript to determine whether a file exists in a directory?
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?