10

In a custom resolver, I wish to modify the resolving behaviour only if the item is being published from a parent publication. IResolver.Resolve() has various parameters which may be useful (but maybe not).

The item parameter gives me the ID of the page (in this case) being published. I have two publications: a parent and a child, so when I publish from the parent with "Also Publish/Unpublish in child publications" selected, I see Resolve() being invoked twice, once for the parent and once for the child. (OK - actually it's 4 times, as I have two publication targets, but for the sake of argument, let's say 2.) I can see the page URI in the parent context, and then on the second invokation, in the child context.

I had hoped the resolve instruction parameter would be useful, but instruction.IncludeChildPublications appears always to be false. (Is this, perhaps, a side-effect of the default resolver being called first?)

I had also hoped the PublishContext would be useful, but context.Publication gives back the same publication as the item is in.

How can I accurately determine that the publish is being invoked via "Also Publish/Unpublish in child publications? Is it possible in a custom resolver? Are there other techniques I could use, such as the events system, or could I even pass data from one to the other?

1
  • Not sure on on the IResolver.Resolve() parameters, but Bart Koopman describes a way to always change a specific parent publication's items in a comment to my post. Mar 5, 2013 at 16:37

1 Answer 1

4

The resolver behavior appears a bit different depending on where it is used.

If you would select to show the Items to Publish in the Publish Dialog, the Resolver is called and it will show true for instruction.IncludeChildPublications. I notice the Resolver being called twice for the same item (the parent one) actually. But this is only a resolve action in the UI, and has no relation to the actual Publish action which will happen once the dialog is confirmed.

However as you have found out, the actual Publish action results in two Publish Transactions which are resolved separately and there the instruction.IncludeChildPublications will always show a value of false.

When you would subscribe to a Page or Component PublishEvent (for example the Initiated phase ), then you can check the PublishEventArgs and in there should should see that args.PublishInstruction.ResolveInstruction.IncludeChildPublications has a value of true. But this event is only triggered for the parent Page (the one you actually selected for Publish) and doesn't give you any relationship back to the Resolvers which happen afterwards.

So I think the conclusion must be that you cannot determine in a Resolver if this action was started from a Parent which included it children.

Your Answer

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

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