17
2010
Restricting FieldEditor to specific template based items
In Sitecore 6.2 it is possible to integrate FieldEditors. These are command which enables users edit item settings when they work in the page editor. Personally I think it is a great option when you want editors to only work within the Page Editor, and still let them edit settings.
For the blog module that I created I implemented two FieldEditorCommands which let the user edit the blog and entry settings. When you use the default implementation as described in one of the cookbooks users can always click on the ribbon button regarding if the fields are on the currentitem. When those field don not exist on that item, they just get a empty popup.
I decided to restrict the option only to items which are based on a certain template. You can do this the following way:
You’ll need to override the Execute method in the your class (which overrides from Sitecore.Shell.Applications.WebEdit.Commands.FieldEditorCommand).
Then you isolate the function Context.ClientPage.Start in for instance an if statement.
Example:
[sourcecode language="csharp"]
if (context.Items[0].TemplateID == new ID(Settings.Default.EntryTemplateID))
{
Context.ClientPage.Start(this, “StartFieldEditor”, args);
}
else
{
Context.ClientPage.ClientResponse.Alert(“Please select an entry first”);
}
[/sourcecode]
If anyone else has a better way to get the same results please let me know.
Related Posts
Leave a comment
Who am I
Sitecore blogs
Sitecore blogs
- Sitecore Descriptive Tree List Field Type
- Adding a Publish button in the contextal menu
- Sitecore Searcher and Advanced Database Crawler
- Dutch webinar about faster developing with Sitecore Rocks and VS2010
- Using XAML controls outside the Sitecore folder
- Easily Sanitize a Sitecore Item Name in C#
- Introduction to the Unified Page Editor
- Sitecore.Diagnostics.Assert statements
- Programmatically Add Controls to the HTML Head in Sitecore
- Filtering ECM Dispatcher

An article by Mark




