0

Is there any way to remove the related publish option or always uncheck this option when I publish?

Example

0

2 Answers 2

0

I can think of 2 solutions that will work for you.

  • Customize Publish.xml
  1. Copy Publish.xml file from sitecore\shell\Applications\Dialogs\Publish folder to sitecore\shell\override folder, so that you don’t messed up original file in case if you want to revert back your changes.
  2. Apply Visible="false" on and style="display:none" on <div class="publish-wizard-tooltip"> as below.
<Checkbox ID="PublishRelatedItems" Header="Publish related items"  Visible="false"/>
<div class="publish-wizard-tooltip" style="display:none">
           <ThemedImage Src="office/16x16/information.png" Align="Center" />
           <Literal class="publish-wizard-tooltiptext" Text='${Translate.Text(Texts.PublishesAllReferencesToTheItemThisMayIncreaseTheTimeItTakesToPublish)}' />
</div>

- By customize PublishForm

  1. 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 = false;
                base.PublishRelatedItems.Disabled = true;
            }
        }
    }
}
  1. Compile the solution and put dll in bin folder of website root.
  2. Duplicate Publish.xml file and paste it at \Website\sitecore\shell\Override\Applications\Dialogs\Publish\
  3. 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 changes:
<WizardForm CodeBeside="SitecoreCustom.CustomPublishForm,SitecoreCustom">

The format is <namespace>.<class name>, <assembly name>. For example SitecoreCustom is a namespace, CustomPublishForm is a class name and SitecoreCustom is the assembly name.

  1. Login into Sitecore with the user who is part of sitecore\\ContentEditor role (or any other specific role as per your requirement)

  2. Select an item and try to publish it.

Hope it helps!

2
  • I tried the first method you mentioned, which successfully hides the related publish option. But, if someone publishes the item with this option before, this option will be checked as well even though it has been hidden. So the second approach is more suitable for me?
    – Jack Noob
    Commented Aug 24, 2023 at 8:06
  • Yes, second option works best in your case, also check if you restart your cm server then login back with same user and dose it persist with users last setting of publish related item. If not then first option should work. Commented Aug 24, 2023 at 8:23
0

If you are using the xmcloud and experience edge, you can use this setting:

<settings role:require="XMCloud">
  <setting name="ExperienceEdge.ProcessRelatedItems" set:value="false" />
</settings>

If you are using Experience Platform, I suggest to create a role, based on https://doc.sitecore.com/xp/en/developers/101/platform-administration-and-architecture/the-security-roles.html The custom role can inherits from:

  • Sitecore Client Advanced Publishing
  • Sitecore Client Publishing based on your requirements.

Then you can deny read access to the "/sitecore/system/Settings/Security/Policies/Publish/Can Publish Related Items" in the core database: enter image description here

which hide the option from the dialog: enter image description here

I hope it helps.


Edited: Furthermore, if the users have checked the publish with related item, it is already saved on their profiles. You can check it and reset them, for example with powershell or c# code:

$user = Get-User -Identity "sitecore\testuser"
$user.Profile.GetCustomProperty("/sitecore\testuser/Publish/PublishRelatedItems")
$user.Profile.GetCustomProperty("/sitecore\testuser/Publish/Republish")
$user.Profile.GetCustomProperty("/sitecore\testuser/Publish/PublishChildren")
#Set it to false
$user.Profile.SetCustomProperty("/sitecore\testuser/Publish/PublishRelatedItems",$false)

It need a bit more work, and provided powershell script is just a sample to give you an idea. The Registry cache also need to be updated, maybe if you do a clear cache, you can skip that step.

I suggesst to study these two classes, for creating the correct script:

  • Sitecore.Web.UI.HtmlControls.Registry (see how caching works)
  • Sitecore.Shell.UserOptions

Not the answer you're looking for? Browse other questions tagged or ask your own question.