All of Sitecore developers know that we can restrict publishing for particular Sitecore item. Now if you set publishing restriction for particular item and try to publish that item with subitems, it will not publish that item but it will publish all subitems as there is NO restrction on subitems. So there should be an option by which we can restict subitems publishing as well. Below are some examples which made me think about this publishing restriction option. Sometimes content author or publisher publishes Home item with subitems by mistake Sometimes content author or publisher publishes Media Library item with subitems by mistake. This mistake not only slowed down our stage server but also started publishing all unwanted items.
I have come across this situation many times when my client complains that somebody from content team published Home item with subitems by mistake. This mistake may create disaster for you by publishing all unwanted items on web database which eventually mess up your live website. So we need to jump to stage server to restart app pool in order to stop publishing. But this solution is not at all accepted. Moreover, there is no such feature in Sitecore out of the box which can help us to disable publishing for root item with subitems such as “Home” item. This leads me to write an implementation of disabling publish for root items. Then I got an idea – why not write a module which can help our Sitecore community friends who are in the same boat? Please note that you may have other options but every project has its own existing environment and implemention and sometimes you need to come up with option which can fit into existing implemention.
That’s how Sitecore Publishing Restriction Module gets created. But wait… you may have question “Have you checked Sitecore MarketPlace before creating this module?” The answer is – Yes. I have checked and there is a module named “Sitecore Publishing Exclusions” but sadly it doesn’t support Sitecore 7 version. Hence I needed to write this module which is supported by Sitecore 6+, 7+ and 8+. This is a very userful module which will help you to disable or set warning on publishing for all those items which you want to restrict.
As per above configuration whenever you try to publish “Sitecore“, “Content” or “Home” item, it will show you warning message. This will eliminate accidently publish without seeing which item is selected.
Moreover, you can completely disable publishing option also for such items. You simply need to uncheck show warning checkbox. You can also warn your content publisher users about heavy publishing by configuring Heavy Publishing Restriction options. This feature will be very helpful for Sitecore 6+ and 7+ as there is no extra warning message pop-up like in Sitecore 8 publish. Thanks to my collegue Ashish Bansal for giving idea to add this feature.
You can download this module at Sitecore MarketPlace https://marketplace.sitecore.net/Modules/S/Sitecore_Publishing_Restriction.aspx?sc_lang=en Once you download and install this module, you need to do a little configuration change suggested below.
Need to comment out existing publish command and add new custom publish command as shown below.
<!--<command name="item:publish" type="Sitecore.Shell.Framework.Commands.PublishItem,Sitecore.Kernel" />-->
<command name="item:publish" type="Sitecore.SharedSource.CustomPublish,Sitecore.SharedSource"/>
That’s it, now you are good to go!
Quick q, does this have any issues when an item is auto-published (i.e. programmatically from code)
No, it will not restrict items getting published programmatically. The purpose of this module is to restrict human publish action for desired items.