我想动态修改内容,以便稍后将修改后的版本提供到我主题的内容插槽中。用例是将日历portlet定位在collective.cover行/列/单元格内。
这是我试过的:
<replace css:content="#content .row:nth-child(2) .cell:nth-child(2) .tile.tile-edge">
<!-- These work (meaning levels above current selection CAN be copied) -->
<xsl:copy-of select="." />
<xsl:copy-of select="../.." />
<xsl:copy-of select="/" />
<!-- However, neither of these do -->
<xsl:copy-of css:select=".portletCalendar:first-child" />
<xsl:copy-of select="//div[contains(concat(' ', normalize-space(@class), ' '), ' portletCalendar ')]" />
<xsl:copy-of select="//div[@id='portal-personaltools']" />
</replace>
答案 0 :(得分:3)
可能您遇到的唯一问题是依靠Diazo的工具来翻译XSL命令中的css选择器。仅当目标是当前选定的节点或其子节点时,它才有效。所以,用XPath选择器替换它:
<!-- replace one part of content with another -->
<replace css:content="#content .row:nth-child(2) .cell:nth-child(2) .tile.tile-edge">
<xsl:copy-of select="//dl[@class='portlet portletCalendar']" />
<xsl:apply-templates mode="raw" />
</replace>
<!-- make sure it doesn't show up in two places -->
<drop content="//dl[@class='portlet portletCalendar']" />