3

The use case is as follows:

If an item is published, but some of the component presentations were not rendered, we want to set the status to Warning (but still publish the page(s) as normal). The aim of this is to alert Editors to the fact that they have added content to a page that has not been rendered (ie an invalid content type on the page).

It is easy enough to detect whether some CPs are not rendered by checking the RenderedItem.ChildRenderedItems against the Page component presentations using a TBB in the Page Template, and I have managed to simulate the Warning state and useful error messages on a component by component basis by rendering the missing components against a dummy Component Template which always throws an error.

However, this only works if the number of Render Failures allowed in the Publish Instruction is greater than zero. If it is zero (the default) then the publish transaction fails at the Rendering stage and no content is published (and you get an Error state in the publishing queue).

I tried updating the publish transaction status to Warning in my TBB, and not rendering the error template, however this only works temporarily - on deployment you see that the status goes through the deployment statuses and ends up with Success.

Finally I tried updating the Publish Instruction to set the number of render failures to be 100, however this doesn't work either (I guess this object is not update-able from template code as there is no .Save() method).

Does anyone have any bright ideas how else I can solve this in Template code - I guess there is something I can do in the event system, but I want to avoid this if possible.

4

What you can do is during rendering detect the items, then (as of 2013) you can get publish transaction from your template and set some app data with item ID and message. Finally you can subscribe to PublishTransaction SetPublishedTo event (again as of 2013) and check app data. If app data is there - set state of this transaction to warning. This way you will set Warning state on publish transaction that is in Successful state and is not going to change anymore (unless you will call Undo)

  • Thanks, I think this will be my backup solution, however I would have preferred to change the # of render errors, as this leads to a nice component by component breakdown of invalid content, whereas I guess with the event system, I have to create a block of text in the transaction information property to show feedback in the GUI – Will Price Aug 21 '13 at 17:43

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.