【问题标题】:Extending page table with field using itemsProcFunc in TYPO3 6.2在 TYPO3 6.2 中使用 itemsProcFunc 扩展页表
【发布时间】:2014-12-04 11:45:12
【问题描述】:

我正在尝试通过从扩展中扩展页面 db 表和 TCA 数组来扩展“页面”属性表单。这有效,除了我的自定义函数不会被调用。如果我用 TYPO3 核心函数 itemsProcFunc 行替换我自己的 itemsProcFunc 行,它可以工作,但使用我自己的函数它永远不会工作(我只是得到一个空的结果/选择列表,即使我只是返回一个虚拟数组:“return array('title ','1');"....

这是我在扩展的 ext_tables.php 中的代码:

<?php

$TCA['pages']['columns'] += array(
    'targetelement' => array(
        'exclude' => 0,
        'label' => 'Target element (first select a target page!)',
        'config' => array (
            'type' => 'select',
            'items' => Array (
                Array('',0),
            ),
            'size' => 1,
            'minitems' => 1,
            'maxitems' => 1,
            //'itemsProcFunc' => 'TYPO3\CMS\Backend\View\BackendLayoutView->addBackendLayoutItems',
            'itemsProcFunc' => 'Vendor\Myextension\Controller\Hooks\CustomTargetElementSelector->getContentElements',
        ),
    )
);

t3lib_extMgm::addToAllTCAtypes('pages', 'targetelement,', '2', 'after:nav_title');
t3lib_extMgm::addToAllTCAtypes('pages', 'targetelement', '1,5,4,199,254', 'after:title');

附:当然,我将 Vendor\Myextension 替换为我自己的命名空间。

我不知道把我的函数文件放在哪里,我假设在 extension\Classes\Controllers\Hooks\CustomTargetElementSelector.php。

我的最终目标是显示所选快捷方式页面UID的内容元素列表..

P.s.2 我的 CustomTargetElementSelect.php 文件看起来像这样(内容只返回一个项目,虚拟列表结果:

<?php

namespace Vendor\Myextension\Controller;

class CustomTargetElementsSelector extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

    public function getContentElements(array &$params,$pObj){

        return array('title','uid');

    }
}

【问题讨论】:

    标签: php typo3 typo3-6.2.x


    【解决方案1】:

    首先,itemsProcFunc 应该是一个简单的类;我从未测试过 itemsProcFunc 中是否有 Extbase 控制器上下文。

    你的钩子应该(这只是一个建议)驻留在

    yourext/Classes/Hook/CustomTargetElementSelector.php
    

    命名空间:

    namespace Vendor\Yourext\Hook;
    
    class CustomTargetElementSelector {
    
       [method inside]
    
    }
    

    刷新系统缓存后,如果钩子仍然没有函数,则在函数内设置die()语句,以确定函数是否被调用。目前它无法工作,因为您的类(Controllers/Hooks)和命名空间(Controller)的位置不合适。

    为了完全兼容6.2/7,替换

    t3lib_extMgm::
    

    通过

    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多