7

Is it possible to perform a patch that has to match on more than on attribute?

My issue is that I'd like to patch after:

<sitecore>
  <processors>
    <uiDeleteItems>
      <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="Execute"/>
    </uiDeleteItems>
  </processors>
</sitecore>

Typically, I'd patch with something like:

<sitecore>
  <processors>
    <uiDeleteItems>
      <processor mode="on" type="Custom.DeleteItems, Custom" method="RemoteDelete" patch:after="*[@type='Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel']"/>
    </uiDeleteItems>
  </processors>
</sitecore>

or...

<sitecore>
  <processors>
    <uiDeleteItems>
      <processor mode="on" type="Custom.DeleteItems, Custom" method="RemoteDelete" patch:after="*[@method='Execute']"/>
    </uiDeleteItems>
  </processors>
</sitecore>

The problem is that there are previous processors that match on these descriptors prior to the one I'm targeting:

Method:

<processor type="Sitecore.Buckets.Pipelines.UI.ItemDeleted, Sitecore.Buckets" method="Execute" mode="on" patch:source="Sitecore.Buckets.config"/>

Type (in order they appear):

<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="Confirm"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckTemplateLinks"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckCloneLinks"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckLinks"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckLanguage"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="UncloneItems"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="Execute"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="PostAction"/>

(and many more for type)

So what I really need to do is patch:after when the type and method equal my values. Is this possible out-of-the-box?

-- Edit after side-barring with Hishaam --

Full Showconfig output of elements in question:

<uiDeleteItems>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckPermissions"/>
  <processor type="Sitecore.Buckets.Pipelines.UI.ItemDeleted, Sitecore.Buckets" method="Execute" mode="on" patch:source="Sitecore.Buckets.config"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="Confirm"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckTemplateLinks"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckCloneLinks"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckLinks"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckLanguage"/>
  <processor type="Sitecore.PathAnalyzer.Client.Pipelines.DeleteItems.DeletePathAnalyzerItems,Sitecore.PathAnalyzer.Client" method="CheckDefaultSiteMapGroup" mode="on" patch:source="Sitecore.PathAnalyzer.Client.config"/>
  <processor type="Sitecore.PathAnalyzer.Client.Pipelines.DeleteItems.DeletePathAnalyzerItems,Sitecore.PathAnalyzer.Client" method="CheckMapItems" mode="on" patch:source="Sitecore.PathAnalyzer.Client.config"/>
  <processor type="Sitecore.ContentTesting.Pipelines.DeleteItems.DeleteTestDefinitionItems,Sitecore.ContentTesting" method="CheckActiveTests" mode="on" patch:source="Sitecore.ContentTesting.config"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="UncloneItems"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="Execute"/>
  <processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="PostAction"/>
</uiDeleteItems>

In my case, I can certainly target method="PostAction" and patch:before. I typically like to insert my patches logically, in the event an additional patch is implemented.

Logically, I would say

"My processor should execute after the type='Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel' method='Execute' processor"

Not necessarily "Before the PostAction processor".

I will leave the question open as I'm curious if what I originally asked is possible OOTB.

Also- the new load order technique in Sitecore 9 would provide a mechanism to accomplish what I'm after, but this is on 8.2u4.

  • Yeah out of the box sitecore it should be possible. Try to load your patch at last. By this i mean rename it and put something like zz.mypatch.config – Hishaam Namooya Jun 5 '18 at 16:27
  • I have it set up to load last. But based on the rule, it gets inserted before I'd like it to based on the two other elements that meet the single rule. – jrap Jun 5 '18 at 16:29
  • I would maybe switch it to patch:before and specify type or method that is after the one that is desired. With this, your type will be last one for that method. In your case it would be method="PostAction". – Peter Procházka Jun 5 '18 at 16:32
  • Which version of Sitecore are you on? If you are on Sitecore 9, you can specify load order doc.sitecore.net/sitecore_experience_platform/90/developing/… and set your specific config to be applied first – Peter Procházka Jun 5 '18 at 16:40
12

Looking thru one of my previous projects I recalled seeing this in, you can use an and to meet the attribute values of both your method and type (example):

<!-- patch match on both type and method -->
<processor mode="on" type="Sitecore.Buckets.Pipelines.UI.ItemMove, Sitecore.Buckets" method="Execute"
patch:instead="*[@method='Execute' and @type='Sitecore.Shell.Framework.Pipelines.MoveItems,Sitecore.Kernel']" />

So your patch might resemble something like:

<sitecore>
  <processors>
    <uiDeleteItems>
      <processor mode="on" type="Custom.DeleteItems, Custom" method="RemoteDelete" 
          patch:after="*[@type='Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel' and @method='Execute']"/>
    </uiDeleteItems>
  </processors>
</sitecore>

Additionally, (though I haven't used it in a while but I do believe it is supported) you can also use an indexer to grab which match you want to patch around as well (the last() I have not used in a patch but I believe is xpath supported):

<!-- first in matches -->
<processor patch:instead="*[@method='Execute' and @type='Sitecore.Shell.Framework.Pipelines.MoveItems,Sitecore.Kernel'][0]" />

<!-- last in matches -->
<processor patch:instead="*[@method='Execute' and @type='Sitecore.Shell.Framework.Pipelines.MoveItems,Sitecore.Kernel'][last()]" />
  • Confirmed *[last()] works properly. – jrap Oct 30 at 18:19
3

In order to load the processor in the order you want, what you can do is to load the showconfig.aspx. From the showconfig, you will get the current order.

Let say for example, this is how it looks in showconfig

<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="Confirm"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckTemplateLinks"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckCloneLinks"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckLinks"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="CheckLanguage"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="UncloneItems"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="Execute"/>
<processor mode="on" type="Sitecore.Shell.Framework.Pipelines.DeleteItems,Sitecore.Kernel" method="PostAction"/>

And you want to load your processor between the Execute and PostAction. You just need to use the patch:before the PostAction. Something as below:

<sitecore>
  <processors>
    <uiDeleteItems>
      <processor mode="on" type="Custom.DeleteItems, Custom" method="RemoteDelete" patch:before="*[@method='PostAction']"/>
    </uiDeleteItems>
  </processors>
</sitecore>

Now, if you are on Sitecore 9, you can use the new feature which is the Configuration Layer. This allows you to load files in specific way. You can get more information from those articles:

  1. Sitecore Documentation

  2. Sitecore Configuration Layer

  • patch:before ;) – jrap Jun 5 '18 at 16:42

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.