我正在尝试在站点列表中添加站点名称,以便在 publish:end:remote
上清除 HTML 缓存事件。
<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>
但是,它没有按预期工作。我做了谷歌搜索,没有找到任何关于我们如何在元素之前或之后修补的信息。大多数示例都是 on/before 属性等。
谢谢。
最佳答案
如果要修补没有属性的节点,可以选择要比较的节点的 text() 。之前或之后。看这个例子:
<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>
对您的问题采取不同的方法。
通过补丁删除,您可以清除列表并从头开始构建您的列表。
<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>
关于Sitecore 补丁 - 添加网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33819741/