Sitecore 补丁 - 添加网站

标签 sitecore patch sitecore8.1

我正在尝试在站点列表中添加站点名称,以便在 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/

相关文章:

Sitecore:Glass Mapper 代码优先

c - 从补丁文件中去除C注释的方法

bash - 在Docker中使用sed替换路径

Git 使用补丁

sitecore - 带搜索的多列表字段

sitecore - 如何在 sitecore 7.2 MVC 中渲染 View ..?

asp.net-mvc-3 - Sitecore 和 MVC3

c# - 如何以编程方式填充 Sitecore 项目(添加项目和字段)?

sitecore - 借助 Sitecore,如何使用 cshtml 文件和模型来呈现自定义字段?