我想基於主題參數即時替換我的靜態主題中的class
標記屬性。如何將Diazo主題參數插入某個主題的類屬性?
我嘗試這樣做:
<replace attributes="class" css:theme=".conteudo">conteudo-$section</replace>
這:
<replace css:theme=".conteudo">
<xsl:attribute name="class">conteudo-$section</xsl:attribute>
<xsl:value-of select="."/>
</replace>
即使這樣:
<xsl:template match="//div[contains(concat(' ', normalize-space(@class), ' '), ' conteudo ')]">
<xsl:attribute name="class">
<xsl:value-of select="substring((body/@class), 'section-', 0)" />
</xsl:attribute>
</xsl:template>
因爲我也有其他規則引用.conteudo
元素,它會是也很好地瞭解如何處理這些問題的最佳實踐(在所需的轉換occ之後) (即:
<replace
css:content-children="#portal-column-content"
css:theme-children=".conteudo" />
順便說一句,在'manifest.cfg':部分=蟒蛇: 「─」 + context.getPhysicalPath()[LEN(門戶.getPhysicalPath()):] [0] –
爲了避免在爲資源請求(圖像,CSS,js)計算getPhysicalPath時出現AttributeError,我將manifest.cfg更改爲'section = python:not context_state.is_portal_root()和context_state.portlet_assignable )和context.getPhysicalPath()[len(portal.getPhysicalPath()):] [0]' –
條件的第一部分是在上下文爲站點根時避免IndexError。 –