punktde/nodereplicator

将 Neos 节点结构和内容复制到其他内容维度

安装数: 3,285

依赖者: 0

建议者: 0

安全: 0

星标: 7

关注者: 9

分支: 6

开放问题: 5

类型:neos-package

3.0.4 2023-05-12 08:01 UTC

README

Latest Stable Version Total Downloads License

此包为 NodeType 配置提供额外选项,以便自动更新其他维度中的此节点。

此包解决的问题

场景: 在一个多语言页面中,如果没有配置回退,您想显示地址。地址是内容节点。地址条目应引用一个国家和一个类别。国家和类别也应该是内容节点。尽管类别和国家标题需要翻译成每种语言,但地址本身对于每种语言都保持不变。

问题: 当您将包含内容节点的页面从语言 A 翻译成语言 B 时,您就不再能够添加具有相同标识符的两种语言的节点。没有回退,您需要在每种语言上单独添加地址,并引用相应的节点。

解决方案: 此包在节点类型配置中添加了一个名为 replication 的配置选项。它允许您指定节点是否应该自动复制到父节点已存在的所有维度,并且当更改内容时是否应该更新替代维度中的内容。

配置

选项

    'Vendor.Package:Address':
      superTypes:
        'Neos.Neos:Content': true
      
    ...
      
      options:
        replication:
          structure:
            // Replicate the node itself into the other dimension if the parent exists and the node is missing, default: false
            create: true
            // Create the node as hidden, default: false
            createHidden: true
            // Also delete the node in other dimensions, default: false
            remove: true
    
          // Defaults for all properties of this nodeType 
          properties:
            // defaults false
            update: true
            
            // default false, takes precedence of update
            updateEmptyOnly: true 
    
       properties:
         myProperty:
           options:
             replication:
               // default inherited from node level config
               update: false
               // default inherited from node level config
               updateEmptyOnly: false

示例配置

'Vendor.Package:Address':
  superTypes:
    'Neos.Neos:Content': true
  ...
  
  options:
    replication:
      structure:
        create: true
      properties: 
        update: true
    
'Vendor.Package:AddressCategory':
  superTypes:
    'Neos.Neos:Content': true
  ...
  
  options:  
    replication:
        structure:
            create: true
      
'Vendor.Package:AnotherAddressCategory':
  superTypes:
    'Neos.Neos:Content': true
  ...
  
  options:
      replication:
          structure:
              create: true
          properties:
              updateEmptyOnly: true
      

'Vendor.Package:TranslateableCategory':
  superTypes:
    'Neos.Neos:Content': true
  ...

  options:
      replication:
          structure:
              createHidden: true
          properties:
              updateEmptyOnly: true

# Disable a single property

'Vendor.Package:YetAnotherAddressCategory':
  superTypes:
    'Neos.Neos:Content': true
  ...
  
  options:
      replication:
          structure:
              create: true
          properties:
              update: true
  properties:    
      metaDescription:
        options:
          replication:
            update: false