xml - Xml 中的 If Else 条件

标签 xml magento

我制作了一个自定义模块,并制作了一个 system.xml ,我在其中检查管理员是否要包含 css 如果管理员选择一个我在我的模块 layout.xml 代码中使用下面的 cod 包含 one.css

<action method="addCss" unlessconfig="mymodule/addcss/one"><stylesheet>mymodule/test/two.css</stylesheet></action>


<action method="addCss" ifconfig="mymodule/addcss/one"><stylesheet>mymodule/test/one.css</stylesheet></action>

现在,如果管理员从后端选择否,它会包含在线 two.css,但当管理员选择是时,它会同时包含 css 1 和 css 2.. 我只想实现包含不同不同 css 的 if else 条件。我如何在不使用第三方扩展的情况下实现这一目标。

最佳答案

unlessconfig提到了in the article suggested in Meenakshi's comment由 Aoe_LayoutConditions 扩展添加,不在 Magento 核心中。请参阅 Mage_Core_Model_Layout 了解可用的功能。也就是说,具有 addCss (Mage_Page_Block_Html_Head) 的类也具有用于删除诸如 css 之类的项目的方法。所以你应该能够做到:

<action method="removeItem" ifconfig="mymodule/addcss/one">
    <stylesheet>mymodule/test/two.css</stylesheet>
    <type>skin_css</type>
</action>
<action method="addCss" ifconfig="mymodule/addcss/one">
    <stylesheet>mymodule/test/one.css</stylesheet>
</action>

关于xml - Xml 中的 If Else 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25094863/

相关文章:

mysql - 在magento 1.8.0.0版本中运行mysql复杂查询

java - 将 Java 文件添加到 Android 应用程序

java - 非法参数异常 : no view found for id 0x7f07004e android

c# - 创建具有属性的 XML 元素 C# 有额外的 xmls =""

sql - 使用现有命名空间查询 Oracle 中的 XML 表

php - Paypal 网关为 Magento 商店返回错误

sorting - 如何在 Magento 中对加载的产品集合进行排序?

php - Magento 是否允许按国家/地区对产品级别的特定项目进行订单和运输限制?

c# - Java 等效于 C# XML 签名方法

php - Magento 1.9 Helper 找不到错误