Here is an example:
- The first you will need is a command. You can add it into your command.config, or in a separate .config in \App_config\Include\.
In my example my command is named “commentandrate:opencommenteditoverview” but you can name it as you want of course.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <commands> <command name="commentandrate:opencommenteditoverview" type="MyNamespace.OpenCommentEditOverView, MyDllName"/> </commands> </sitecore> </configuration>
- After that you will only need to write the corresponding class:
using Sitecore; using Sitecore.Diagnostics; using Sitecore.Resources; using Sitecore.Shell.Framework.Commands; using Sitecore.Text; using Sitecore.Web; using Sitecore.Web.UI.Framework.Scripts; using Sitecore.Web.UI.Sheer; using Sitecore.Web.UI.XamlSharp.Continuations; namespace MyNamespace { public class OpenCommentEditOverView : Command, ISupportsContinuation { // Methods public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length == 1) { //Check if the tab is already open and refresh it is needed if (WebUtil.GetFormValue("scEditorTabs").Contains("commentandrate:opencommenteditoverview")) { SheerResponse.Eval("scContent.onEditorTabClick(null, null, 'OpenCommentEditOverView')"); } else //Open a new tab { //The Path to the aspx file to dsplay in this tab UrlString urlString = new UrlString("/sitecore/shell/Applications/LBi/CommentEditOverView.aspx"); context.Items[0].Uri.AddToUrlString(urlString); UIUtil.AddContentDatabaseParameter(urlString); //urlString["fld"] = "__Tracking"; SheerResponse.Eval(new ShowEditorTab { Command = "commentandrate:opencommenteditoverview", Header = "Comments", Icon = Images.GetThemedImageSource("Network/16x16/lock.png"), Url = urlString.ToString(), Id = "OpenCommentEditOverView", Closeable = true }.ToString()); } } } } }
You can for example add a button in a toolbar.
If you don’t know what is a chunk, a strip, … please refer to this post: http://sitecoreblog.blogspot.be/2010/11/use-contextual-button.html
To create this new button:
- Switch to the core database
- In /sitecore/content/Applications/Content Editor/Ribbons/Chunks, add a new “Chunk” (template: /sitecore/templates/System/Ribbon/Chunk)
- Fill in the fields:
- Header: The name who will appear below the block of button
- ID: an ID
- Below this chunk, add a new item of type /sitecore/templates/System/Ribbon/Large Button
- Fill in the fields:
- Header: The name who will appear below the block of button
- Icon: The icon of this button
- Click: you command name (as in the .config)
- Tooltip: the text when you let the mouse on this button
- To include this chunk in the “Home” toolbar, go in /sitecore/content/Applications/Content Editor/Ribbons/Strips/Home
- Add a new subitem (template: /sitecore/templates/System/Reference)
- And fill in the Reference field (example of value: sitecore/content/Applications/Content Editor/Ribbons/Chunks/Comment Rate Admin)
No comments:
Post a Comment