duanmaifu3428 2014-12-04 11:45
浏览 44

使用TYPO3 6.2中的itemsProcFunc扩展包含字段的页表

I'm trying to extend the 'page' properties form by extending the page db table and TCA array from within an extension. This works, except that my custom function won't be called. If I replace my own itemsProcFunc line with a TYPO3 core function itemsProcFunc line it works, but with my own function it never works (I just get an empty result/selectlist, even when I simply return a dummy array: "return array('title','1');"....

Here's my code in my extension's 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');

P.s. I replace Vendor\Myextension for my own namespace of course.

I don't know where to put my function file exactly, I assume in extension\Classes\Controllers\Hooks\CustomTargetElementSelector.php.

My ultimate goal is to display a list of content elements of the selected shortcut page UID..

P.s.2 my CustomTargetElementSelect.php file looks like this (contents just return a single item, dummy list result:

<?php

namespace Vendor\Myextension\Controller;

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

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

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

    }
}
  • 写回答

1条回答 默认 最新

  • dongyan1899 2014-12-04 22:09
    关注

    First of all, an itemsProcFunc should be a simple class; I never tested if an Extbase controller context is available in an itemsProcFunc.

    Your hook should (this is just a recommendation) reside in

    yourext/Classes/Hook/CustomTargetElementSelector.php
    

    Namespace:

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

    After flushing the system cache, if the hook still has no function, set a die() statement within the function to find out if the function is called at all. Currently it cannot work because the location of your class (Controllers/Hooks) and the namespace (Controller) don't fit.

    For the sake of full 6.2/7 compatibility, replace

    t3lib_extMgm::
    

    by

    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?