php - TYPO3 Extbase 后端模块。模板路径问题

标签 php path content-management-system typo3 extbase

我在创建 extbase/fluid 扩展时遇到了一个奇怪的问题。 我用的是 TYPO3 6.1

我在我的开发服务器上使用后端模块进行了扩展(与产品相同的配置/硬件)。该模块与模板路径完美配合:

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 =
    }
}

这是设置:

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}
    }
}

最佳答案

主要问题是如果根路径中没有模板,错别字配置将不会加载到存储文件夹或页面上。

解释: 您将为您的扩展设置的错别字配置,无论它是在 ext_typoscript_setup 中,一个静态模板还是通过 php,它总是需要在页面根目录某处的系统记录模板。否则它不会被渲染 - 并且不会为您的 extbase 扩展设置路径,因此默认布局、模板和部分路径已设置,这就是脚本将查找您的东西的地方。

默认为:

/Private/Resources/Layout/
/Private/Resources/Partials/
/Private/Resources/Templates/@Controllername/@Actionname

如果您需要为后端模块覆盖这些,您可以通过直接在 Controller 中注入(inject) View 设置来解决该问题。

<?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(){

}

}

希望对你有帮助 问候本吉

关于php - TYPO3 Extbase 后端模块。模板路径问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16807390/

相关文章:

php - 需要在一个字段中搜索两个值Mysql

php - 从 JSON 数组创建 HTML 表

javascript - 将动态内容加载到页面

JAVAFX:找不到文件的相对路径

php - 将表格暴露给 View

php - 将按钮值提交给 Controller 但未能发布该值

C中获取FreeType字体路径列表的跨平台方法

java - 获取库的路径 - Java

ruby-on-rails - Refinery CMS 查询 - 呈现 :body content 时 content_for 的 NoMethodError

python - 如何将 django shop 与 django cms 集成?