Diazo - 有条件地向主题元素添加一个类 [英] Diazo - Conditionally add a class to a theme element

查看:34
本文介绍了Diazo - 有条件地向主题元素添加一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有在满足某些条件时,我才需要向来自主题的元素添加一个类.我试过这个解决方案,通过替换重氮调整prependbefore :

I need to add a class to an element coming from the theme only if certain conditions are met. I've tried this solution, adjusted for Diazo by replacing prepend with before:

<before css:theme=".main" if-content="not(//*[@id='portal-column-two'])"><xsl:attribute name="class"><xsl:value-of select="//*[@class='main']/@class"/> full</xsl:attribute></before>

但我收到以下错误:

XSLTApplyError: xsl:attribute: Cannot add attributes to an element if children have been already added to the element.

即使我删除了所有其他规则,例如只有 规则和 规则,我也会收到该错误.

I get that error even when I remove all other rules such that there is only the <theme> rule and the <before> rule.

仅当内容中没有 #portal-column-two 元素时,如何才能向主题元素添加类?

How can I add a class to a theme element only when there is no #portal-column-two element in the content?

推荐答案

prepend css:theme 的 Diazo 替换是 before css:theme-children,而不是 在 css:theme 之前.您的示例适用于已更改的内容.

The Diazo replacement for prepend css:theme is before css:theme-children, not before css:theme. Your example works with that changed.

这篇关于Diazo - 有条件地向主题元素添加一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆