This blog describes publishing restrictions, which can restrict the items and version of each item in each language that the Sitecore ASP.NET web Content Management System publishes. Publishing restrictions control whether Sitecore can publish an item, whether Sitecore can publish a version of an item, and the publishing targets to which Sitecore can publish an item and its versions.
For each item, Sitecore can maintain field values in multiple languages. For each language, Sitecore can maintain multiple versions of each field value. You can apply publishing restrictions to items and to each versions in each language. If Sitecore cannot publish an item, it cannot publish any versions of that item or any of its descendants. Publishing restrictions that you apply to versions do not apply to descendants. Under some conditions, Sitecore items can appear with or without descendants in publishing target databases in which they contain no versions in one or more languages.
To configure publishing restrictions in the Content Editor, click the Publish tab, and then in the Restrictions group, click Change. The Publishing Settings dialog appears. To configure publishing restrictions for an individual version, click the Versions tab:
The checkboxes control whether Sitecore can publish the version. The dates control the period during which Sitecore can publish the version. If Sitecore cannot publish a version of an item, it can still publish the item itself, including its descendants.
To configure publishing restrictions for the entire item and all of its descendants, click the Item tab:
To specify the publishing targets to which Sitecore should publish the item, click the Targets tab:
If you specify no publishing targets, Sitecore can publish the item to all publishing targets. By default, Sitecore publishes all content to all publishing targets.
The workflow state associated with an item can function as a publishing restriction. Sitecore does not publish versions associated with non-final workflow state.
To summarize, to determine whether to publish an item to a publishing target databases, Sitecore evaluates:
To determine which version of an item to publish in a language, Sitecore uses the publishable version created most recently, accounting for the following in each version:
Configuring publishing restrictions does not control when Sitecore publishes. If you configure an item to publish only after a specific date and time, Sitecore does not publish it at that date and time. The publishes after that date and time that includes that item publishes that item.
Hi John Suppose I have a couple of targets: Is there a way to restrict the publish of an item to one target (using the second tab option), but at the same time allow the publish to the other targets? Kind of a combination of tab 2 and tab 3: Tab 2 should only reflect on targets that are not checked in tab 3. Thanks! Kind regards Brecht
@Brecht: If I understand correctly, you want to control the publication date for each item (not each version) to individual publishing targets. I don't think this is possible by default, but I think it would be possible to implement a custom solution such as a publishItem pipeline processor that checks some fields you add to the standard template. You could do this without overriding the Sitecore UI, but it might not be very user-friendly. Can you describe the use case (what you need to do, why you would want to do this, how the UI should appear to the user, or anything else)? I don't think I've seen this requirement before, but if it seems common or important, I might be able to try to prototype something.
Our setup is the following We are in a transition period where we already moved all data from an older CMS to Sitecore. The frontend is still hosted apart from Sitecore, reading from a custom SQL database. We added custom handlers allowing a save to that database on publish. We have a setup with two targets: internet and preview. (In Sitecore terms, preview would be the master, while internet refers to the web database) Each has its own custom database and frontend. When a user saves an item, an eventhandler will enter and publish the item to the preview database. The real publish (after workflow approved state) is always to the internet. A normal user isn't aware of the preview publish. The use case: A user is granted to put restrictions on items, for example to prevent the item to appear before an allowed date. He does want to preview this item though before appearing online. But the publish restriction won't allow the item to be published on the preview target either. That's why we are looking for a mechanism to control the restriction per target. UI-wise it could be visualized like this: http://bit.ly/ZzSJp0 (conceptual, everything is fine if the result is the same). Thanks!
Thanks for providing these details. I have seen similar requirements to publish to a preview database before publishing to production. I can imagine a few possible solutions. One might be to implement something like this: sitecoreblog.alexshyba.com/.../publish-to-pre-production-web-database.html Does your solution ever have items that you do *not* want to publish the latest versions of all immediately to preview? I mean, do you have to maintain separate publishing dates for each publishing target, or can you publish everything to preview and use the Sitecore standard publishing restrictions field to restrict publishing only to the other target? The less you have to customize the UI and add fields to the standard template, the better. In that case, I think you could configure a solution based on this that would return the default (the value corresponding method in the base class) for all publishing targets, and return the latest only for your preview target.
Hi John Thanks for pointing us in the right direction. We do indeed always need to publish to the preview target and only restrict the publish to the other one. We managed to do something like that in our code. Thanks for your help.
Hi John, This publish restrictions blog is very useful for me. We want to publish our site but exclude few items for example blog items to publish which are having status "Approved" only. This we want to restrict while publishing our whole site. Thanks in advance for your help.
You don't want to publish the item, or you do not want to publish any version of the item? I mean, do you want to prevent Sitecore from publishing the entire item, or only the current version? If you put a version into a non-final workflow state, Sitecore should not publish it by default, so I think the easiest way to control this is workflow. If you need to prevent publication of the item, I have a few possible approaches.
John, Thanks for your response, can you explain that few possible approaches. Thanks in advance.
There are several options; your choice may depend further on your requirements and level of experience developing with Sitecore. If possible, I would absolutely try to use workflow. If you can't use workflow, then I would try to use publishing restrictions. 1. You could apply some logic (events, scheduled process, workflow action, or anything along those lines) to update the publishing restrictions for the item. 2. You could add a processor to the publishItems pipeline to prevent publication of these items. 3. Maybe you could override Sitecore.Workflows.Simple.WorkflowProvider, specifically IsApproved(), to apply your logic. If you find that Sitecore publishes items with no versions (or more likely, it doesn't remove items from the publishing target database after you restrict publishing of or delete versions from the Master database), I think you could do something like this: 4. www.sitecore.net/.../Delete-Items-without-Versions-from-the-Sitecore-ASPNET-CMS.aspx There are probably other possible approaches.
John, Items are displaying properly when publish programmatically; whereas all items (including not approved) are displaying through sitecore publish. This issue occurred after upgraded Sitecore from 6.4 to 6.5 or some other issue with Lucene indexing or some other unknown issue. Please suggest how to solve this with sitecore publish item. Thanks in advance.
I have not seen this issue before. Would it be possible to rebuild all of the Lucene indexes and then republish the entire database? I think more likely you may have a configuration issue, specifically in the /configuraiton/sitecore/sites section of the web.config file, causing your content delivery site/environment to read from the Master database instead of the Web (publishing target) database. If you log into the Sitecore desktop, use the icon in the lower right corner to select the publishing target database, and open the Content Editor, do you see the content that Sitecore should not have published? Or do you only see that content when you actually access the published site? I mean, how do you know that Sitecore published those versions that were in non-final workflow states? Remember to switch back to the Master database after working with the publishing target database.
John, Today I have tried with "rebuild all of the Lucene indexes" and published item. First time it alerted the message "The current item “BABY” is in the workflow state “Awaiting Approval” and will not be published. Are sure you want to publish?" We published it, after on wards it is publishing with out alert message, even we created new item. Please suggest me. Thanks
@Satyendra: I think this issue could be difficult to diagnose in blog comments. It could be related to configuration or customization, as Sitecore by default does not publish versions with publishing restrictions, including workflow state. I would suggest that you file a support case and/or post on the SDN forums and/or StackOverflow.
Hi John. A colleague and I are discussing presently real world situations where it would be desirable to publish/unpublish historical versions. I came up with seasonal content where v1 might be Spring, v2 Summer, etc. however, this doesn't feel quite right. I would imagine that my IA would represent seasonal content differently either in the form or attributions or in some other manner. Can you shed some light on how you've seen multi-version publishing restrictions used? Thanks! Tim
Can you explain the "Publishable To" field? Does that allow for the specified version to be deleted/removed/unpublished from the target DB? Example: I have 2 versions of an item and in version no. 2 I have set publishing restrictions of "publish from" 1/1/2014 and a "publish to" of 1/5/2014. So when 1/1/2014 comes and a publish occurs, this item will be published (say to production). But when 1/5/2014 comes along it will then be deleted/removed/unpublished? I'm trying to figure out the best way to handle how to remove items from production environment after a certain date automatically.