Reputation: 17373
I'm trying to add site name on list of sites so that HTML cache gets cleared on publish:end:remote
event.
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site patch:after="*[@site]">mysite</site>
</sites>
</handler>
<handler type="Sitecore.Publishing.RenderingParametersCacheClearer, Sitecore.Kernel" method="ClearCache"/>
</event>
However it isn't working as expected. I did googling and didn't find anything on how we can patch before or after an element. Most of the examples are on/before attribute etc.
Thanks.
Upvotes: 5
Views: 1866
Reputation: 1879
This has been already answered but adding to the answer above- while patching the sites you don't need to add other element attributes but only the ones you are patching.
<sitecore>
<events>
<!-- Html Cache clear on publish events -->
<!-- Force FULL cache clear on publish-->
<event name="publish:end">
<handler>
<sites>
<site name="customSite">customSite</site>
</sites>
</handler>
</event>
<!-- Html Cache clear on publish events -->
<!-- Force FULL cache clear on publish-->
<event name="publish:end:remote">
<handler>
<sites>
<site name="customSite">customSite</site>
</sites>
</handler>
</event>
</events>
Upvotes: 0
Reputation: 3487
If you want to patch a node without attributes, you can select the text() of the node to compair. before or after. see this Example:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites>
<site patch:before="site[./text()='website']">plop3</site>
</sites>
</handler>
</event>
</events>
</sitecore>
</configuration>
A different approach to your issue. With a patch delete you can clear the list and build your list from scratch.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<patch:delete />
</sites>
<sites hint="list">
<site>website</site>
<site>anotherwebsite</site>
</sites>
</handler>
</event>
</events>
</sitecore>
</configuration>
Upvotes: 9
Reputation: 27132
You don't need to use any patch:delete
or patch:instead
. You just need to add name
attribute to your new <site>
tags so Sitecore will treat them as a separate site definitions.
Here is some further explanation: Config patching system for the external config files
Create App_config\Include\My.Site.Definition.config
file with content:
<sitecore>
<sites>
<site name="mysite" patch:before="site[@name='website']"
... />
</sites>
<events>
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site name="mysite">mysite</site>
</sites>
</handler>
</event>
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site name="mysite">mysite</site>
</sites>
</handler>
</event>
</events>
</sitecore>
The other option would be to use some other tags instead of <site>
tag, cause when the parent tag contains hint="list"
attribute, it treats all the children tags as items for that list. You would need to make sure that every tag is unique. You can use it like that:
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site1>mysite</site1>
<othersite>othersite</othersite>
</sites>
</handler>
</event>
Upvotes: 5
Reputation: 4118
You don't have to patch list of sites. You need to add all your websites one by one.
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site>SiteOne</site>
<site>Sitetwo</site>
...
<site>SiteN</site>
</sites>
</handler>
</event>
Upvotes: 0