【问题标题】:How to fill select options from custom database in .yaml files using typo3-neos?如何使用typo3-neos从.yaml文件中的自定义数据库中填充选择选项?
【发布时间】:2015-02-13 07:38:32
【问题描述】:

我目前正在为我的项目使用typo3-neos,我遇到了这个问题。 我尝试在 .yaml 文件中制作这样的自定义节点

'TYPO3.Designs:SomeItem':
  superTypes:
    - 'TYPO3.Neos:Content'
  ui:
    group: 'structure'
    label: 'Some Item'
    icon: 'icon-columns'
    inlineEditable: true
    inspector:
      groups:
        document:
          label: 'Item options'
          position: 1
  properties:
    someitem:
    type: string
    defaultValue: 'item1'
    ui:
      label: 'Alignment'
      reloadIfChanged: TRUE
      inspector:
         group: 'document'
         editor: 'TYPO3.Neos/Inspector/Editors/SelectBoxEditor'
         editorOptions:
           values:
             item1:
               label: 'item1'
             item2:
               label: 'item2'
             right:
               label: 'item3'

在这部分

editorOptions:
 values:
  item1:
    label: 'item1'
  item2:
    label: 'item2'
  right:
    label: 'item3'

我想从数据库中获取数据,所以如果数据库中有 10 个项目,它会在编辑器中显示 10 个选项。

我该怎么做? 任何帮助表示赞赏,谢谢

【问题讨论】:

    标签: php yaml typo3-flow neoscms


    【解决方案1】:

    可能代码是这样的:

    将此添加到您的模型中

    <?php
    namespace Acme\YourPackage\DataSource;
    
    use TYPO3\Neos\Service\DataSource\AbstractDataSource;
    use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
    
    class TestDataSource extends AbstractDataSource {
    
            /**
             * @var string
             */
            static protected $identifier = 'acme-yourpackage-test';
    
            /**
             * Get data
             *
             * @param NodeInterface $node The node that is currently edited (optional)
             * @param array $arguments Additional arguments (key / value)
             * @return array JSON serializable data
             */
            public function getData(NodeInterface $node = NULL, array $arguments) {
                    return isset($arguments['integers']) ? array(1, 2, 3) : array('a', 'b', 'c');
            }
    
    }
    

    这是 yaml 设置:

    questions:
      ui:
        inspector:
          editor: 'Content/Inspector/Editors/SelectBoxEditor'
          editorOptions:
            dataSourceIdentifier: 'questions'
            # alternatively using a custom uri:
            # dataSourceUri: 'custom-route/end-point'
    

    从'soee'http://docs.typo3.org/neos/TYPO3NeosDocumentation/IntegratorGuide/ContentStructure.html得到这个参考

    【讨论】:

      猜你喜欢
      • 2016-05-27
      • 1970-01-01
      • 2021-12-24
      • 2017-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多