【问题标题】:IRRE relations from tt_content to tt_content in fluid styled content流体样式内容中从 tt_content 到 tt_content 的 IRRE 关系
【发布时间】:2016-11-24 11:01:49
【问题描述】:

我有一个fluid_styled_content 元素,它们有IRRE 元素,它们也是fluid_styled_content 元素。如何获取 IRRE 元素?

目前我正在尝试使用自定义 DataProcessor 获取它们,但我不知道如何实际获取元素。看起来,父元素存储子元素的数量,而子元素将父元素的 uid 存储在 foreign_field 中。有什么想法吗?

虽然我在 DataProcessor 中确实有 ContentObjectRenderer,但我很伤心,我不知道如何实际获取这些元素。我试过$cObj->cObjGet,但没用。

【问题讨论】:

    标签: typo3 fluid-styled-content


    【解决方案1】:

    我努力让它工作,我用我的自定义 DataProcessor 做到了。在此处了解有关自定义数据处理器的更多信息:https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/7.6/AddingYourOwnContentElements/Index.html#data-processor

    这是处理器本身:

    /**
     * @param  ContentObjectRenderer $cObj                       The data of the content element or page
     * @param  array                 $contentObjectConfiguration The configuration of Content Object
     * @param  array                 $processorConfiguration     The configuration of this processor
     * @param  array                 $processedData              Key/value store of processed data (e.g. to be passed to a Fluid View)
     * @return array                                             the processed data as key/value store
     */
    public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
    {
        $table = $processorConfiguration['references.']['table'];
        $fieldName = $processorConfiguration['references.']['fieldName'];
    
        $irreElements = $cObj->getRecords(
            $table,
            [
                'where' => $fieldName.'='.$cObj->data['uid'],
                'orderBy' => 'sorting'
            ]
        );
    
        $targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration);
        $processedData[$targetVariableName] = $irreElements;
    
        return $processedData;
    }
    

    这是 TypoScript 配置

    tt_content {
        services < lib.fluidContent
        services {
            templateName = Services.html
            dataProcessing {
                23 = Vendor\ExtensionName\DataProcessing\WhateverYouWantToCallItProcessor
                23 {
                    references.fieldName = service
                    references.table = tt_content
                    as = serviceElements
                }
            }
        }
    }
    

    【讨论】:

      【解决方案2】:

      看看这里:

      https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/frontend/Classes/DataProcessing/DatabaseQueryProcessor.php

      tt_content {
          accordion =< lib.default
          accordion {
              templateName = ABC
              dataProcessing {
                  20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
                  20 {
                      table = tx_irre_element
                      pidInList.field = pid
                      where {
                          data = field:uid
                          intval = 1
                          wrap = tt_content=|
                      }
      
                      orderBy = sorting
                      as = items
                  }
              }
          }
      }
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-09
      • 1970-01-01
      • 2018-12-07
      • 2012-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多