2

I'm working with a DataProvider that I want live on BOTH of my databases and want the items to always be unpublishable (that way the items on one database don't get written to the Sitecore database should the data-provider accidentally be turned off)

one way to do this is to use the NeverPublish field, which causes the items to be deleted if they are accidentally published (but doesn't cause a problem on the other database as the dataprovider just recreates them) However, I dont want to take the performance hit for deleting items on every publish.

Is there a field that can be set to simply Skip and item from being published?

5

Yes. But to do so, you need to invoke a feature that I am willing to bet only 1% of the 1% knows about.

For a dataProvider, you can disable groups of functionality. In your case you want to disable publishing.

For completeness, I'm showing a few examples. All in your <dataProvider> element:

<dataProvider ...>
  <disable>*</disable>
  <enable>GetItem</enable>
  <enable>GetChildren</enable>
</dataProvider>

Disable everything on your dataProvider except methods GetItem and GetChildren.

But to make things easier, there are "method groups" you can disable. To disable publishing entirely for your dataProvider, do this:

<dataProvider ...>
 <disableGroup>publishing</disableGroup>
</dataProvider>

For more information of this forgotten feature from the past, see: The dataProvider Element

If I recall correctly (it's been a very long while since I used this), Sitecore will not throw exceptions or anything when these disabled calls are invoked; rather just silently ignore them and move on.

Edited to add

So I did a bit of investigation. Sitecore has updated the flexibility around this a bit more, so it is possible that this method will be easier for you.

If you look in App_Config/Sitecore.config for how the <database id="web"> is wired up, you will see an example of this. It states:

  <dataProviders hint="list:AddDataProvider">
    <dataProvider ref="dataProviders/main" param1="$(id)">
      <disableGroup>publishing</disableGroup>
      <prefetch hint="raw:AddPrefetch">
        <sc.include file="/App_Config/Prefetch/Common.config" />
        <sc.include file="/App_Config/Prefetch/Webdb.config" />
      </prefetch>
    </dataProvider>
  </dataProviders>

Notice how it maps in the "main" data provider, and then tells it to <disableGroup> publishing. This is why the system doesn't break when you do a publish via the UI when you've switched to the "web" database - it simply gets ignored.

So you can either disable this group for your dataProvider entirely, or you can optionally disable it per-database for your provider.

If I recall correctly (as can be seen in a modern day Sitecore.config) you can also just remove sections from this part of the configuration.

<methodGroups>
  <copyMove>
    <CopyItem />
    <MoveItem />
  </copyMove>
  <create>
    <AddVersion />
    <CreateItem />
  </create>
  <delete>
    <DeleteItem />
    <RemoveVersion />
    <RemoveVersions />
  </delete>
  <properties>
    <GetProperty />
    <RemoveProperty />
    <SetProperty />
  </properties>
  <publishing>
    <AddToPublishQueue />
    <CleanupPublishQueue />
    <GetPublishQueue />
  </publishing>
  <query>
    <SelectIDs />
    <SelectSingleID />
  </query>
  <read>
    <BlobStreamExists />
    <GetItemDefinition />
    <GetItemFields />
    <GetItemVersions />
  </read>
  <relations>
    <GetChildIDs />
    <GetParentID />
    <GetRootID />
    <HasChildren />
  </relations>
  <resolve>
    <ResolvePath />
  </resolve>
  <templates>
    <ChangeTemplate />
    <GetTemplateItemIds />
    <GetTemplates />
  </templates>
  <update>
    <SaveItem />
  </update>
  <workflow>
    <GetItemsInWorkflowState />
    <GetWorkflowInfo />
    <SetWorkflowInfo />
  </workflow>
</methodGroups>

Removing the <publishing> element should have the same effect as the above, which removes group publishing.

| improve this answer | |
0

You may can set up publishing restrictions and select a far date in 'Publishable From' field e.g

Official Documentation https://doc.sitecore.com/users/82/sitecore-experience-platform/en/set-up-publishing-restrictions-for-an-item.html

List of fields which control publishing restrictions https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/fields-that-control-publishing-restrictions-in-the-sitecore-asp-net-cms

| improve this answer | |
0

You can create a new fake publishing target under /sitecore/system/Publishing targets and for those specific items, publish to that fake target. Them master would never overwrite web because it would be diverted to the fake target.

| improve this answer | |
  • Wouldnt sitecore throw an exception because the database does not exist (at least I think I got something like that in the past with phantom publishing targets) – Adam Hess Oct 3 '19 at 15:17

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.