carbon/condition

此软件包提供了一些融合辅助功能,使编写条件(`@if`)更简单。

资助软件包维护!
jonnitto
www.paypal.me/Jonnitto/20eur

安装: 51,099

依赖项: 5

建议者: 0

安全性: 0

星标: 3

关注者: 2

分支: 0

开放问题: 0

类型:neos-carbon

2.0.0 2022-03-29 07:49 UTC

This package is auto-updated.

Last update: 2024-08-29 04:41:36 UTC


README

Latest Stable Version Total Downloads License GitHub forks GitHub stars GitHub watchers

Carbon.Condition 软件包用于 Neos CMS

此软件包提供了一些融合辅助功能,使编写条件(@if)更简单。
您可以在这里查看一个真实世界的示例

安装

Carbon.Condition 通过 packagist 提供。将 "carbon/condition" : "^2.0" 添加到 composer.json 的 require 部分,或运行 composer require carbon/condition

Carbon.Condition:Case

链接到融合文件
如果内容元素或节点类型定义位于文档中,则返回 true。
示例用法

value = 'FooBar'
value.@if.render = Carbon.Condition:Case {
    content {
        nodeType = 'Foo.Bar:NodeType'
        propertyFilter = '[row != "one"]'
    }
}

在上面的示例中,如果当前文档中存在节点类型 Foo.Bar:NodeType 且属性 row 设置为非 one,则仅渲染值 FooBar

value = 'FooBar'
value.@if.render = Carbon.Condition:Case {
    document.nodeType = 'Foo.Bar:MixinNodeType'
}

在上面的示例中,如果文档包含 mixin Foo.Bar:MixinNodeType,则仅渲染值 FooBar

您也可以混合条件

value = 'FooBar'
value.@if.render = Carbon.Condition:Case {
    content {
        nodeType = 'Foo.Bar:MixinLightbox'
        propertyFilter = '[lightbox=true]'
    }
    document {
        nodeType = 'Foo.Bar:MixinLightbox'
        propertyFilter = '[lightbox=true]'
    }
}

在上面的示例中,如果文档或内容元素包含 mixin Foo.Bar:MixinLightbox 且属性 lightbox 设置为 true,则仅渲染值 FooBar

默认值

node = ${documentNode}

enabled = true

content {
    collection = '[instanceof Neos.Neos:ContentCollection]'
    nodeType = null
    propertyFilter = ''
    filter = ${this.nodeType ? ('[instanceof ' + this.nodeType + ']' + this.propertyFilter) : null}
}

document {
    nodeType = null
    propertyFilter = ''
    filter = ${this.nodeType ? ('[instanceof ' + this.nodeType + ']' + this.propertyFilter) : null}
}

context {
    backend = true
    live = false
}

属性概览

Carbon.Condition:Properties

链接到融合文件
检查元素是否应该被渲染的辅助工具。示例用法

@if.render = Carbon.Condition:Properties {
    properties = 'title,image'
}

在上面的示例中,只有当节点具有 titleimage 设置时,条件才返回 true

默认值

node = ${node}

properties = null
operator = 'AND'

context {
    backend = true
    live = false
}

属性概览