我构建了一个扩展程序,我想在将插件添加到页面时添加插件选项
Extension Name : hotels
在酒店模特中,
<?php
class Hotel{
... get set methods ...
}
?>
<?php
namespace TYPO3\Hotels\Controller;
class HotelController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController{
public function listAction(){
// $this->view->assign('result', array('test' => 'hello, u r in list')); }
}
?>
在ext_localconf.php
中 \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.' . $_EXTKEY,
'hotels',
array('Hotel' => 'list,single,display,update,save,preview,edit')
);
在ext_tables.php中
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'hotels',
'list of Hotels'
);
$pluginSignature = str_replace('_','',$_EXTKEY) . '_hotels';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] ='pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_myhotel.xml');
不知何故,我想我错过了一些东西。这给出了一个错误:
我可以在添加扩展时在后端看到该选项,但是当我想显示(查看)我添加该扩展名的页面时,会生成错误。
----> The default controller for extension "Hotels" and plugin "hotels" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.
请指导我
答案 0 :(得分:3)
在TYPO3 6.x中,建议您使用命名空间类,并告诉configurePlugin
方法您的供应商名称。
由于您没有包含任何控制器代码,我将尝试草绘它:
*Action
后缀EXT:myext / Classes / Controller / HotelController
namespace MyVendor\MyExt\Controller;
class HotelController {
/**
* @return void
*/
public function listAction(){
}
}
接下来,在configurePlugin中提到名称空间,如下所示:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'MyVendor.' . $_EXTKEY,
// UpperCamelCase please, refer to [1]
'Hotels',
array('Hotel' => 'list,single,display,update,save,preview,edit')
);
这允许类定位器正确解析类。
要验证它,请确保重新安装扩展程序。
PS:请尽可能在6.x中使用命名空间类。旧的Tx_*
类只是别名,并为解释器增加了额外的负担。
1 - TYPO3 API Docs for ExtensionUtility::configurePlugin()
<强>更新强>
有很多可能的错误。
switchableControllerActions
?f:link.action
(或分别是f:uri.action)不喜欢没有合适的controller
属性HotelController
,该文件必须位于Classes/Controller/HotelController.php
,然后对configurePlugin()
进行调整以反映我所描述的vendorName < / LI>
醇>
答案 1 :(得分:0)
试试吧。
在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',
)
);
在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缓存并删除typo3temp数据