3

I added another checkbox to the publish dialog, and I'm trying to get it to the pipeline processors. I extended 'PublishOptions' and added a property for my checkbox, thinking they'd be available in the processor(s), but they aren't. Perhaps I should override PublishStrategy.Publish and put data into job.Options.CustomData which is available in the processors?

Why are publish job parameters null in my processor? I thought it would be the same as what was put on the job processing queue (has two objects in parameters array).

Populated parameters: Populated Parameters

Null parameters: enter image description here

3
  • What is the functionality of the added checkbox? Commented Jul 24, 2017 at 18:12
  • I did something similar with the publishing targets- sitecoresolver.blogspot.com Hope this will give you some more insights.
    – Amitabh
    Commented Jul 25, 2017 at 11:11
  • @HishaamNamooya we reflected/modified the default 'publish related items' processor, and we were hoping to use a checkbox to enable that modification else it would work as normal.
    – MStodd
    Commented Jul 26, 2017 at 17:23

1 Answer 1

2

Instead of going and overriding the different Sitecore Publishing Processors, you may achieve it in a simpler way.

enter image description here

You will need to keep your custom checkbox on the Publishing Dialog and then, when the user clicks on the Publish button, you retrieve the value of the custom checkbox.

Once you see if the checkbox is checked, you store it on an item. You need to add a handler to the publish:itemProcessing. From there you can check if the value of the checkbox on the item is checked or not.

public void OnItemProcessed(object sender, EventArgs args)
{
    var itemArgs = args as ItemProcessedEventArgs;

    if (itemArgs != null)
    {
        var publishContext = itemArgs.Context.PublishContext;

        // Your Logic here
    }
}

For performance gain, you can put the value into a custom cache and using the job handle, you will know if the job is completed or not. When the job is completed, you need to clear the custom cache so that for the next publish, it needs to retrieve the latest value.

This method will only require an update on the Publishing Dialog which you already did. It will not require the overriding of other processors.

You can read my post here for more information on how I used the event publish:itemProcessed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.