Ensuring related content is published in a bundle is now made easier with the latest release of Sitecore 7.2

As you know if you've been reading the blog, the release of Sitecore 7.2 has us pretty excited. One of the things that most stood out to me was the enhancements for related item publishing, as our team has been coming up with workarounds for similar issues in many of our past projects. 

What are you talking about, Jason?

I'm glad you asked! With site publishing, the issue of related items doesn't usually come up. Whether it's incremental, smart, or a full republish, things that are changing (usually) get pushed.

Note: There are some fixes in 7.2 that address certain scenarios for incremental publishing, so you may want to take a look at the fixes shipped with this build and see if it addresses any issues you may be having with incremental publishing.

The scenario we usually run into, however, is targeted publishing of specific items. This can either be triggered by the user in the authoring environment or via publish actions in a workflow approval process. In previous versions of Sitecore, there was some basic related publishing happening in the PublishItem pipeline that would pull in clones and File Drop media. We'd have to build in new events to find components that authors had added to the page being published, as well as referenced media items, and publish all of those related items and their parents along with the selected item.

And all that is fixed now?

No, it isn't completely fixed, but there are some major improvements. The first thing that has happened is that authors now have an option on the item publishing dialog to select to publish related items, defaulted to 'true' so that authors have to explicitly turn it off.

Publishing Dialog Options

This checkbox triggers the new getItemReferences pipeline that has been added to the publishing flow. By default, this new pipeline publishes "clones, aliases, related media items, and items that the current item refers to in the link database."

The second big piece is that the PublishAction that we often use in the workflows has some additional parameters, including whether to trigger related publishing. By default, if not specified, related publishing will not occur, so I would suggest adding that 'related=1' onto your publish action in 7.2 so you can start reaping the benefits of the new pipeline. You can find the other new parameters in the release notes.

Note: The Sample Workflow shipped with 7.2 still only uses the deep=1 parameter, so if you use the Sample Workflow with Sitecore, make sure you are updating the parameters on the Auto Publish action as well.

My specific test was to add some subfolders in the media library, and then upload an image. Next I referenced that image in a Rich Text field on a new page and pushed it through the default sample workflow. The page was published, but the image was not because its parent folders were not published, and I had not included related=1 in the PublishAction.

Then I repeated the test using the Publish Item wizard, but this time selected "Publish Related Items." The image and its parent folders were published immediately!

What if the item links don't reference all the items that I want to bundle in the publish?

Now that the references code is in its own pipeline, you can add your own classes directly into the publishing pipeline to run any logic you want to return lists of items that you also want pulled forward into the publish. I cannot overemphasize how awesome it is to drive the logic at the publishing pipeline this easily and not be hooked into events.

Have you tried out the related item publishing with your authors? What has your experience been?

comments powered by Disqus