Recently I’d stumbled upon a post on Sitecore Community regarding how to make Publish Related Items checkbox always checked based on a specific User Role.
Original question: I need to make 'Publish Related Items' checked every time any content editor publishes an item. It will be nice if I can do it via Roles. But, if I can’t then I would like to default it for every user in Sitecore.
This can be achieved by overriding sitecore\shell\Applications\Dialogs\Publish\Publish.xml form and make PublishRelatedItems checkbox checked and disabled. Below steps illustrates how to make PublishRelatedItems checkbox always checked based on a specific User Role:
Original question: I need to make 'Publish Related Items' checked every time any content editor publishes an item. It will be nice if I can do it via Roles. But, if I can’t then I would like to default it for every user in Sitecore.
This can be achieved by overriding sitecore\shell\Applications\Dialogs\Publish\Publish.xml form and make PublishRelatedItems checkbox checked and disabled. Below steps illustrates how to make PublishRelatedItems checkbox always checked based on a specific User Role:
- Create a new C# class library project and override the OnLoad method of the PublishForm class and add the following code:
using Sitecore; using Sitecore.Diagnostics; using Sitecore.Shell; using Sitecore.Shell.Applications.Dialogs.Publish; using Sitecore.Web; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SitecoreCustom { class CustomPublishForm : PublishForm { public CustomPublishForm() : base() { } protected override void OnLoad(System.EventArgs e) { base.OnLoad(e); //Modify role as per your requirement if (Sitecore.Context.User.IsInRole("sitecore\\ContentEditor")) { base.PublishRelatedItems.Checked = true; base.PublishRelatedItems.Disabled = true; } } } }
- Compile the solution and put dll in bin folder of website root.
- Duplicate Publish.xml file and paste it at \Website\sitecore\shell\Override\Applications\Dialogs\Publish\
- Open Publish.xml which we have just duplicated and update Publish Form code-beside class to use our custom code-beside class instead of Sitecore's default class.
You have to make below change:<WizardForm CodeBeside="SitecoreCustom.CustomPublishForm,SitecoreCustom">
The format is “<namespace>.<class name>, <assembly name>”. For example: SitecoreCustom is namespace, CustomPublishForm is class name and SitecoreCustom is assembly name. - Login into Sitecore with user who is part of sitecore\\ContentEditor role (or any other specific role as per your requirement)
- Select an item and try to publish it. You will see that Publish Related Items checkbox is already checked and disabled.
0 comments :
Post a Comment