Dav*_*mot 3 php typo3 path content-management-system extbase
我在使用extbase/fluid扩展创建时遇到了一个奇怪的问题.我使用TYPO3 6.1
我在我的开发服务器上使用后端模块进行了扩展(与prod相同的配置/硬件).该模块与模板的路径完美配合:
myext/Resources/Private/Backend/Templates
myext/Resources/Private/Backend/Layouts
myext/Resources/Private/Backend/Partials
在此之后,我在ext管理器中下载了我的扩展名zip,然后在prod服务器上下载了安装程序.现在我无法使用我的扩展,因为模块找不到模板.我以相同的方式配置了扩展.模板是在正确的道路上.
我测试将我的文件夹移动到父级别:
myext/Resources/Private/Templates
myext/Resources/Private/Layouts
myext/Resources/Private/Partials
使用它可以工作,但在模块配置中,我指定了"Backend /"文件夹的正确路径.
我不会在Private文件夹中移动我的文件夹,我希望它在Private/Backend文件夹中运行.
我已将扩展静态模板包含在网站根TS模板中.
这是常数:
module.tx_myext {
view {
# cat=module.tx_myext/file; type=string; label=Path to template root (BE)
templateRootPath = EXT:wng_myext/Resources/Private/Backend/Templates/
# cat=module.tx_myext/file; type=string; label=Path to template partials (BE)
partialRootPath = EXT:wng_myext/Resources/Private/Backend/Partials/
# cat=module.tx_myext/file; type=string; label=Path to template layouts (BE)
layoutRootPath = EXT:wng_myext/Resources/Private/Backend/Layouts/
}
persistence {
# cat=module.tx_myext//a; type=string; label=Default storage PID
storagePid =
}
}
Run Code Online (Sandbox Code Playgroud)
这是设置:
module.tx_myext {
persistence {
storagePid = {$module.tx_myext.persistence.storagePid}
}
view {
templateRootPath = {$module.tx_myext.view.templateRootPath}
partialRootPath = {$module.tx_myext.view.partialRootPath}
layoutRootPath = {$module.tx_myext.view.layoutRootPath}
}
}
Run Code Online (Sandbox Code Playgroud)
主要问题是,如果根路径中没有模板,则不会在存储文件夹或页面上加载typoscript配置.
解释: 你将为扩展设置的typoscript配置,它是在ext_typoscript_setup,静态模板或通过php,它总是需要在页面根目录的某个地方的系统记录模板.否则它将不会被渲染 - 并且不会发生extbase扩展的路径设置,因此设置了默认布局,模板和部分路径,这就是脚本将查找内容的位置.
默认是:
/Private/Resources/Layout/
/Private/Resources/Partials/
/Private/Resources/Templates/@Controllername/@Actionname
Run Code Online (Sandbox Code Playgroud)
如果您需要为后端模块覆盖这些,则可以通过直接在控制器中注入视图的设置来解决该问题.
<?php
namespace VendorKey\ExtensionName\Controller;
class SettingsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* Initializes the controller before invoking an action method.
* @return void
*/
protected function initializeAction() {
$this->setBackendModuleTemplates();
}
/**
* Set Backend Module Templates
* @return void
*/
private function setBackendModuleTemplates(){
$frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$viewConfiguration = array(
'view' => array(
'templateRootPath' => 'EXT:extension_name/Resources/Private/Templates/Modules/',
'partialRootPath' => 'EXT:extension_name/Resources/Private/Partials/Modules/',
'layoutRootPath' => 'EXT:extension_name/Resources/Private/Layouts/Modules/',
)
);
$this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $viewConfiguration));
}
/**
* action settings
* @return void
*/
public function settingsAction(){
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这有助于greetz benji
| 归档时间: |
|
| 查看次数: |
5682 次 |
| 最近记录: |