punktde/nodereplicator

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

安装次数: 3,288

依赖: 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