Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
835 views
in Technique[技术] by (71.8m points)

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

I built an extension and I would like to add plugin options at the time of adding the plugin to the page

 Extension Name : hotels

in Hotel model ,

 <?php
    class Hotel{
          ... get set methods ...
      }
  ?>

in HotelController.php

 <?php
  namespace TYPO3HotelsController; 

   class HotelController extends TYPO3CMSExtbaseMvcControllerActionController{

    public function listAction(){
      //    $this->view->assign('result', array('test' => 'hello, u r in list'));               }
   }
 ?>

in ext_localconf.php

 TYPO3CMSExtbaseUtilityExtensionUtility::configurePlugin(
    'TYPO3.' . $_EXTKEY,
    'hotels',
     array('Hotel' => 'list,single,display,update,save,preview,edit')
    );

in ext_tables.php

  TYPO3CMSExtbaseUtilityExtensionUtility::registerPlugin(
    $_EXTKEY,
    'hotels',
   'list of Hotels'
   );

 $pluginSignature = str_replace('_','',$_EXTKEY) . '_hotels';

 $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] ='pi_flexform';

TYPO3CMSCoreUtilityExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_myhotel.xml');

Somehow, I think i'm missing something. This gives an error :

I can see the option in backend side at time of adding extension but when i want to show (view) that Page where I add that extension , generates an error .

----> The default controller for extension "Hotels" and plugin "hotels" can not be determined. Please check for TYPO3CMSExtbaseUtilityExtensionUtility::configurePlugin() in your ext_localconf.php.

Please Guide me

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 MyVendorMyExtController;
class HotelController {
    /**
    * @return void
    */
     public function listAction(){
     }
}

Next, mention the namespace in configurePlugin like this:

TYPO3CMSExtbaseUtilityExtensionUtility::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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...