| John's profileJohn West Blogs about Si...PhotosBlogLists | Help |
|
4/29/2008 Add Page Editor to the Publish tab in Sitecore 6While setting layout settings using Device Editor in Sitecore, I'm too lazy to select the Publish tab before opening Page Editor to see the changes. I want the Page Editor button on the Presentation tab too.
Update: Alternatively, you can copy /sitecore/content/Applications/Content Editor/Ribbons/Strips/Presentation/Layout to /sitecore/content/Applications/Content Editor/Ribbons/Strips/Publish. 4/2/2008 Sitecore UI Command to Copy Item's Template's Path to the Windows ClipboardUpdated: See the comment at the end of this entry before bothering to read it. While writing technical documentation for Sitecore 6, I must frequently refer to the data template associated with an item using the fully qualified path (/sitecore/templates/folder/…/template). I have added a command to the Show chunk in the developer tab to prompt with this value and ask if it should be copied to the clipboard. Implementation 1. Compile the following code into a Visual Studio project. using System; using System.Collections.Specialized; namespace Sitecore.Starterkit.Shell.Framework.Commands.Clipboard { public class CopyTemplatePathToClipboard : Sitecore.Shell.Framework.Commands.Command { public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context) { if (context.Items.Length == 1) { Sitecore.Data.Items.Item item = context.Items[0]; NameValueCollection parameters = new NameValueCollection(); parameters["id"] = item.ID.ToString(); parameters["database"] = item.Database.Name; Context.ClientPage.Start(this, "Run", parameters); } } public override Sitecore.Shell.Framework.Commands.CommandState QueryState(Sitecore.Shell.Framework.Commands.CommandContext context) { Sitecore.Diagnostics.Error.AssertObject(context, "context"); if (context.Items.Length != 1) { return Sitecore.Shell.Framework.Commands.CommandState.Hidden; } if (!UIUtil.IsIE()) { return Sitecore.Shell.Framework.Commands.CommandState.Hidden; } return base.QueryState(context); }
protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args) { Sitecore.Data.Items.Item itm = Sitecore.Configuration.Factory.GetDatabase(args.Parameters["database"]).GetItem(args.Parameters["id"]).Template;
if (args.IsPostBack) { if (args.Result == "yes") { Sitecore.Web.UI.Sheer.SheerResponse.Eval("window.clipboardData.setData(\"Text\", \"" + itm.Paths.FullPath + "\")"); } } else { Sitecore.Web.UI.Sheer.SheerResponse.Confirm(Sitecore.Globalization.Translate.Text("The path to the template associated with the current item is\n\n{0}\n\nDo you want to copy it to the clipboard", new object[] { itm.Paths.FullPath })); args.WaitForPostBack(); } } } } 2. Add this line to /App_Config/commands.config: <command name="clipboard:copytemplatepathtoclipboard" type="Sitecore.Starterkit.Shell.Framework.Commands.Clipboard.CopyTemplatePathToClipboard,Sitecore.Starterkit" /> 3. Create an item named TemplatePath under /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Show/TemplatePath based on the /sitecore/templates/System/Ribbon/Small Button template (I had to implement this feature due to constantly copying paths like this one). As a shortcut, just duplicate the existing Path item with a new name. 4. Set Header to Template Path. 5. Set Icon to applications/16x16/window_dialog.png. 6. Set Click to clipboard:copytemplatepathtoclipboard. 7. Set Tooltip to Copy the path of the template associated with the current item to the clipboard. It only takes a few facts and a tool to figure out how to customize the UI like this. Right-click the tab strip to enable or disable the developer tab. The Sitecore core database controls the user interface using commands defined in /App_Config/Config. Use Lutz Roeder’s Reflector for .NET (http://www.aisto.com/roeder/dotnet) to replicate existing functionality, in this case the Path command in the Show group of the Developer tab. To manage the core database, select core using the icon in the task bar in the desktop, then open Content Editor. Under Applications, find Content Editor. Expand Ribbons, Strips and Chunks (groups) to investigate how the system assembles the ribbon. The Developer tab uses the Show group defined under /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Show. The /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Show/Path item corresponds to the Path command. According to /App_Config/Commands.config, this command invokes Sitecore.Shell.Framework.Commands.Clipboard.CopyPathToClipboard. Use Reflector to copy the relevant code from this class to a custom class and update as needed. I expect this might work on 5.3, possibly with slight modifications. If I hadn't documented the process, this might have saved me time. |
|
|