2

Publishing Targets are unchecked by default

I have 5 publishing targets and when I need to publish any item, I need to go to

Publish --> Change --> Publishing Setting --> Targets

and I will see all Publishing Targets are unchecked. I need to manually check them every time.

Is there a way to let the system to check them by default?

  • 2
    Hi Jinglun, by default they are unchecked because it assumes that you intend the items to be published to all targets. Only check these here if you want to restrict to a specific target (or region). The publishing dialog provides you with an option to check/uncheck the targets and that will persist each time you attempt to publish. – Michael West Aug 29 at 15:20
1

The Publishing Restriction is used per item and as Michael mention in his comment, by default all the publishing targets will not be checked. This is because Sitecore assumes that you will publish to all configured target databases.

The publish restriction allows you to decide whether this item should be publish to a specific target database but also

  • You can decide which version can be publish

  • When should Sitecore be allowed to publish the item

More information about Publish Restriction can be found here.

If you have an item which should only be published to a specific target database, then, you should check the target database name in the Target Tab.

If you want to publish to a specific target database, upon clicking on the Publish button, it allows you to select to which database you want to publish (see screenshot below).

enter image description here

1

To have all checkboxes checked by default, Navigate to Publishing section of About Us item and check all targets in Publishing targets field as shown below and then if you open the dialog Publishing Settings dialog, it would render all checkboxes in checked state.

enter image description here

Explanation -

Targets tab in the Publishing Settings screen is rendered by file \sitecore\shell\Applications\Content Manager\Dialogs\Set Publishing\Set Publishing.xml

It uses Sitecore.Shell.Applications.ContentManager.Dialogs.SetPublishing.SetPublishingForm class from Sitecore.Client dll

and here below is the function to render that tab

/// <summary>Renders the target tab.</summary>
/// <param name="item">The item.</param>
private void RenderTargetTab(Item item)
{
  Assert.ArgumentNotNull((object) item, nameof (item));
  Sitecore.Data.Fields.Field field = item.Fields[FieldIDs.PublishingTargets];
  if (field == null)
    return;
  Item obj = Context.ContentDatabase.Items["/sitecore/system/publishing targets"];
  if (obj == null)
    return;
  StringBuilder stringBuilder = new StringBuilder();
  string str1 = field.Value;
  foreach (Item child in obj.Children)
  {
    string str2 = str1.IndexOf(child.ID.ToString(), StringComparison.InvariantCulture) >= 0 ? " checked=\"true\"" : string.Empty;
    string str3 = string.Empty;
    if (this.ReadOnly)
      str3 = " disabled=\"true\"";
    stringBuilder.Append("<input id=\"pb_" + ShortID.Encode(child.ID) + "\" name=\"pb_" + ShortID.Encode(child.ID) + "\" class=\"scRibbonCheckbox\" type=\"checkbox\"" + str2 + str3 + " style=\"vertical-align:middle\"/>");
    stringBuilder.Append(child.GetUIDisplayName());
    stringBuilder.Append("<br/>");
  }
  this.PublishingTargets.InnerHtml = stringBuilder.ToString();
}

This function loops through all publishing targets and compares each target value on the current item's Publishing target field values to render the checkbox in a checked state.

Hope this answers your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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