Publishing

The publishing module sets up a published and unpublished version of all the content types it applies to.  Non-editor users see the published version.  By default editor users see the unpublished version, but can switch to the published version if they wish.  The module sets up the button to publish the unpublished version, which simply copies the unpublished version to the published version, creating it if it does not exist.

The publishing module should be used with the soft delete module. This facilitates a content editor going to the unpublished version of a content item and deleting it. This deletion can be 'published' i.e applied to the published version by switching to the 'Existed' version on the version control on the bottom toolbar, to show deleted unpublished item, then publishing this item, which has the effect of soft-deleting the published version, making it invisible to anonymous users.

If for some reason it is desired to remove the published version of a content item, a content editor can do this simply by changing the current version to 'Published' and deleting the published version.

Setting up the publishing module

The publishing module requires adding the IsPubVersion, Published (date published), PubFrom and PubTo fields to the ContentItems table. This can be done by running the script at /Areas/Lynicon.Base/Admin/SQL/PublishingInit.sql.

Configuring the publishing module

.UseModule<Publishing>((Func<Type, bool>)(t => !(new Type[] { typeof(User), typeof(SpecsDocContent) }.Contains(t))))

.UseModule<Publishing>((Func<Type, bool>)(t => !(new Type[] { typeof(User) }.Contains(t))),
	(Func<object, bool>)(o => !((o is SpecsDocContent) && ((SpecsDocContent)o).Check1 == true)))


The publishing module can be set up with the following arguments to UseModule:

  • publishingType, a function from Type to a bool, to return true if the content type should have publishing functionality
  • optionally, publishableItem, a function from object (the item) to a bool, to return true if a specific item can be published

Ensuring a content type can be published

A content type can be published if:

  • Its container type implements IPublishable
  • When input to the PublishingType function, the content type returns true
  • When input to the PublishableItem function, the content item returns true

Enabling pre-publish validation for a content type

If a content type implements IPublishIssues, it can run validation checks which must succeed before the system will allow it to be published.  This is a good point to do validation as content should be able to exist in a partially complete or inconsistent state up to the point where it is publically visible.

Adding the publishing module to a site with existing content

When the publishing module is added to a site with existing content, all content items will have a 'null' flag indicating their published version. This content will initially be visible in both Unpublished and Published versions of the site i.e. to content editors and to anonymous users. This avoids all the content vanishing as soon as you deploy the site with the publishing module activated.

As soon as a content item in this intial state is edited, it will only exist in the Published state and will need to be published as normal for anonymous users to be able to see it. If a content item is published from its initial state, it will now exist as two versions with the same content, published and unpublished.

For predictability you can go to the Filters page, select all the publishable items, and use the publish button there to publish them all in one go, ensuring that all your content items are properly set up for publishing.

Finding and publishing changed items

The publishing module adds a special filter to the Filters page. When you drag the Publishing filter into the Active Filters region it has the following fields you can use to set filters based on publishing state:

  • Show checkbox: when checked, the item listing shows the publishing state of every item
  • Never published checkbox: when checked, filter to only items which have never been published (i.e. there is no published version)
  • Requiring publishing checkbox: when checked, filter to only items which require publishing (i.e. their unpublished version has been changed more recently than the published version)

The publishing module also adds a bulk action button (red) for publishing all items selected on the current list in one go.