The default controller for extension and plugin can not be determined ERROR in TYPO3

本小妞迷上赌 提交于 2019-11-29 18:09:47
Cedric Ziel

In TYPO3 6.x, you are advised to use namespaced classes and tell the configurePlugin method your vendor name.

As you didnt include any of your controller code, I'll try to sketch it:

  1. At first, make sure, you use a namespaced controller class-remember to set a Vendor name.
  2. Make sure, your actions are named with the *Action suffix

EXT: myext/Classes/Controller/HotelController

namespace MyVendor\MyExt\Controller;
class HotelController {
    /**
    * @return void
    */
     public function listAction(){
     }
}

Next, mention the namespace in configurePlugin like this:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyVendor.' . $_EXTKEY,
    // UpperCamelCase please, refer to [1]
    'Hotels',
     array('Hotel' => 'list,single,display,update,save,preview,edit')
);

This allows the class locator to resolve the classes correctly.

To verify it, make sure you re-install your extension.

PS: Please use the namespaced classes whenever possible in 6.x. The old Tx_* classes are only aliases and put additional load on your interpreter.

1 - TYPO3 API Docs for ExtensionUtility::configurePlugin()

Update:

There is a multitude of possible errors.

  1. You wired a FlexForm. Did you set the switchableControllerActions appropriately?
  2. One thing I saw more than once: The f:link.action (or f:uri.action respectively) doesnt like to be without an appropriate controller attribute
  3. You clearly missed the namespace concept :) Rename your ControllerClass to HotelController and the file must live in Classes/Controller/HotelController.php, then do the adjustments to configurePlugin() to reflect the vendorName as I described

Try it.

in ext_localconf.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'TYPO3.' . $_EXTKEY,
    'hotels',
    array(
        'Hotel' => 'list,single,display,update,save,preview,edit'
    ),
    // non-cacheable actions
    array(
        'Hotel' => 'list',
    )
);

in ext_tables.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    $_EXTKEY,
    'hotels',
    'list of Hotels'
);

$extensionName  = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY);
$pluginSignature = strtolower($extensionName). '_hotels';


if (TYPO3_MODE === 'BE') {

    /**
     * Registers a Backend Module
     */
    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
        'TYPO3.' . $_EXTKEY,
        'web',   // Make module a submodule of 'web'
        'hotels',   // Submodule key
        '',                     // Position
        array(
            'Hotel' => 'list,single,display,update,save,preview,edit'
        ),
        array(
            'access' => 'user,group',
            'icon'   => 'EXT:' . $_EXTKEY . '/ext_icon.gif',
            'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_hotels.xlf',
        )
    );

}

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Hotels List');

@Clear cache and remove typo3temp data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!