1

I wrote a custom resolver that, when a Component (having components link) is published, it is restricting the components to publish depending upon the schema. My issue is that, the Resolve function resolveditems is not getting populated with resolved items. The count of item is only one even though the component being published have 2 or more component links.

public void Resolve(IdentifiableObject item, ResolveInstruction instruction, PublishContext context, Tridion.Collections.ISet<ResolvedItem> resolvedItems)
{
    var capiTargetPartName = "CAPI v2";
    var capiComponentTemplateName = "CAPI.v2";
    
    //Here when i check the count of resolvedItems, it always returns 1
    log.Info("::- Start CapiComponentResolver-1:: resolvedItems.Count = " + resolvedItems.Count, LoggerCategory.Publishing);
    log.Info(":: Item is " + item.Title);
    
    if (item is Component && context.PublicationTarget.Title.Contains(capiTargetPartName) && (instruction.Purpose == ResolvePurpose.Publish || instruction.Purpose == ResolvePurpose.RePublish))
    {
        // Logic to restrict the publshing
    }
}
6
  • Are you deploying your custom resolver as an Addon? (with Addon service) Nov 17, 2021 at 11:34
  • no @MariovanderHoeven-Riesebos. I am deploying it usual way, installing the dll in GAC, and configuring the config file on Publisher server.
    – vishal
    Nov 18, 2021 at 7:03
  • make sure that you also deploy it on a CMS server (assuming you have a scaled out infrastructure), or else you will not see the results of your custom resolver in the Publish Dialog "Show items to publish". Nov 18, 2021 at 10:21
  • 1) first look to see if anything is resolved by the standard resolvers (in the publish dialog). If anything is listed there, then it should also be in your resolvedItems collection in your custom resolver. If not, then you should review your assumption of what should be published when you publish an item. (See Alvin's link below). Nov 18, 2021 at 10:25
  • Thanks @MariovanderHoeven-Riesebos. So As per you comment, i also deployed it on CMS server.(yes we have scaled out infra). will the resolved item by the standard resolvers(in the publish dialog) will only resolve by the custom resolver. Its strange while checking in publish dialog it is showing only one item, but when we are doing the publish we are seeing two item in the publishing queue for publishing.
    – vishal
    Nov 18, 2021 at 16:22

2 Answers 2

3

In Tridion Sites 9.1, by default publishing will resolve items that link to a Published item, rather than the items linked from the queued item.

Refer to my blog post for an explanation of behavior.

You can confirm expected resolved items by checking "items to publish" without the custom resolver. For your use case, try publishing the linked items to see if your custom resolver is behaving as expected.

Note that the items linked from your queued item might not be resolved, but still published from template code. This will happen through AddBinary() or RenderComponentPresentation(). As of Tridion Sites 9.6, however, templateless data-only publishing will add binaries to the publishing package automatically. :-)

0

EDIT: it seems my issue is caused by the Addon deployment; it will execute (addon) custom resolvers BEFORE the standard (OOTB) ones, including the DXA resolver. There is no way to configure it any other way, nor is there a way to configure the execution order of multiple custom resolvers (from multiple addons): Custom Resolver Addon always has empty resolvedItems collection

I run into the same issue on 9.5: My custom resolver (addon, deployed with addon service) needs to manipulate the items in the resolvedItems collection (let's say I need to remove some items based on some criteria).

However, the resolvedItems collection never contains any items. So, "Show items to publish" gives me at least 1 item, but resolvedItems collection count is always 0.

With 9.0, I would look at the order of resolvers in the Tridion.ContentManager.config (and make sure my custom resolver is executed AFTER any other (default) resolvers), but that is not possible right now.

At this point I have no idea how I can configure my Addon so that resolvers are executed in the right order.

  <resolving>
<mappings>
  <clear />
  <add itemType="Tridion.ContentManager.CommunicationManagement.Page">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.PageResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
      <add type="Sdl.Web.DXAResolver.Resolver" assembly="Sdl.Web.DXAResolver, Version=2.2.9.0, Culture=neutral, PublicKeyToken=b9a30ebcbde732e4" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.CommunicationManagement.PageTemplate">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.PageTemplateResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.ContentManagement.Component">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.ComponentResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
      <add type="Sdl.Web.DXAResolver.Resolver" assembly="Sdl.Web.DXAResolver, Version=2.2.9.0, Culture=neutral, PublicKeyToken=b9a30ebcbde732e4" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.External.ExternalComponent">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.ComponentResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.CommunicationManagement.ComponentTemplate">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.ComponentTemplateResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
      <add type="Sdl.Web.DXAResolver.Resolver" assembly="Sdl.Web.DXAResolver, Version=2.2.9.0, Culture=neutral, PublicKeyToken=b9a30ebcbde732e4" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.CommunicationManagement.Publication">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.PublicationResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
      <add type="Tridion.Extensions.ContextExpressions.ContextExpressionContainerResolver" assembly="Tridion.Extensions.ContextExpressions, Version=9.5.0.0, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.CommunicationManagement.StructureGroup">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.StructureGroupResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
      <add type="Sdl.Web.DXAResolver.Resolver" assembly="Sdl.Web.DXAResolver, Version=2.2.9.0, Culture=neutral, PublicKeyToken=b9a30ebcbde732e4" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.ContentManagement.Category">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.CategoryResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.ContentManagement.Bundle">
    <resolvers>
      <add type="Tridion.ContentManager.Publishing.Resolving.BundleResolver" assembly="Tridion.ContentManager.Publishing, Version=9.5.0.0, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.AudienceManagement.TargetGroup">
    <resolvers>
      <add type="Tridion.Extensions.ContextExpressions.ContextExpressionResolver" assembly="Tridion.Extensions.ContextExpressions, Version=9.5.0.0, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b" />
    </resolvers>
  </add>
  <add itemType="Tridion.ContentManager.ContentManagement.Folder">
    <resolvers>
      <add type="Tridion.Extensions.ContextExpressions.ContextExpressionContainerResolver" assembly="Tridion.Extensions.ContextExpressions, Version=9.5.0.0, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b" />
    </resolvers>
  </add>
</mappings>

Note that the example in the documentation actually manipulates the resolvedItems collection, so it is safe to asume that should still be possible.

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.