Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php TYPO3 Extbase后端模块。模板路径问题_Php_Path_Content Management System_Typo3_Extbase - Fatal编程技术网

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

Php TYPO3 Extbase后端模块。模板路径问题,php,path,content-management-system,typo3,extbase,Php,Path,Content Management System,Typo3,Extbase,我在创建extbase/fluid扩展时遇到了一个奇怪的问题。 我使用typo36.1 我在我的开发服务器上做了一个带有后端模块的扩展(与prod的配置/硬件相同)。该模块与模板的路径完美配合: myext/Resources/Private/Backend/Templates myext/Resources/Private/Backend/Layouts myext/Resources/Private/Backend/Partials 在此之后,我在ext manager中下载了扩展的zip,

我在创建extbase/fluid扩展时遇到了一个奇怪的问题。 我使用typo36.1

我在我的开发服务器上做了一个带有后端模块的扩展(与prod的配置/硬件相同)。该模块与模板的路径完美配合:

myext/Resources/Private/Backend/Templates
myext/Resources/Private/Backend/Layouts
myext/Resources/Private/Backend/Partials

在此之后,我在ext manager中下载了扩展的zip,然后在prod服务器上安装。现在我无法使用扩展,因为模块找不到模板。 我用同样的方法配置了扩展。模板位于正确的路径中

我测试将文件夹移动到父级:

myext/Resources/Private/Templates
myext/Resources/Private/Layouts
myext/Resources/Private/Partials

这样可以工作,但在模块配置中,我指定了“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}
    }
}

我不知道你的设置,但通常你必须像这样在/Configuration/TypoScript/setup.txt中设置这些路径

module.tx_yourext {
    persistence {
        storagePid = {$pid}
    }
    view {
        templateRootPath = {$templateRootPath}
        partialRootPath = {$partialRootPath}
        layoutRootPath = {$layoutRootPath}
    }
}
在添加扩展的静态模板之前,不会使用此配置。您还应该将这些行添加到ext_tables.php

if (TYPO3_MODE === 'BE') {
    Tx_Extbase_Utility_Extension::registerModule(
        $_EXTKEY,
        'web',          // Main area
        'mod1',         // Name of the module
        '',             // Position of the module
        array(          // Allowed controller action combinations
            'Controller' => 'actionName'
        ),
        array(          // Additional configuration
            'access'    => 'user,group',
            'icon'      => 'EXT:my_ext/ext_icon.gif',
            'labels'    => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xml',
        )
    );
}

尝试清理所有缓存,即使是在typo3temp/Core/Cache(或类似的东西)

中,主要问题是如果根路径中没有模板,键入脚本配置将无法加载到存储文件夹或页面上

解释: 无论是在ext_typoscript_设置中,还是在静态模板中,还是通过php,您都将为扩展设置typoscript配置。它始终需要在页面根目录中的某个位置设置系统记录模板。否则它将不会被渲染,并且不会为extbase扩展设置路径,因此默认的布局、模板和部分路径将被设置,脚本将在这里查找您的内容

默认值为:

/Private/Resources/Layout/
/Private/Resources/Partials/
/Private/Resources/Templates/@Controllername/@Actionname
如果需要为后端模块覆盖这些设置,可以通过将视图的设置直接注入控制器来解决该问题

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

}

}

正如@benjamin kott所解释的,TYPO3的后端模块配置需要首先加载。不幸的是,默认情况下扩展名的键入脚本文件不会自动加载

使TYPO3意识到此打字脚本文件的一种方法是在扩展名的根文件夹中创建两个文件:

  • ext\u typoscript\u constants.txt

    <INCLUDE_TYPOSCRIPT: source="FILE:EXT:myext/Configuration/TypoScript/constants.txt">
    
    <INCLUDE_TYPOSCRIPT: source="FILE:EXT:myext/Configuration/TypoScript/setup.txt">
    
  • (有点明显,但是:您应该用您的路径替换此路径)


    添加此文件后,应重新安装扩展以查看更改。您可以使用TypoScript对象浏览器查看是否正在加载设置和常量。

    尽管此线程非常旧,但我想向大家展示我的TYPO3 7.6 LTS解决方案

    首先,您需要通过
    模板>编辑整个记录>包含
    来包含打字脚本文件

    在打字脚本中,您需要使用
    templateRootPath.0
    而不是
    templateRootPath

    module.tx_extension {
        view {
            templateRootPaths.0 = EXT:extension/Resources/Private/Backend/Templates/
            partialRootPaths.0 = EXT:extension/Resources/Private/Backend/Partials/
            layoutRootPaths.0 = EXT:extension/Resources/Private/Backend/Layouts/
        }
    }
    

    我已将静态模板添加到网站根模板中。我已经更新了我的问题。你检查过TS设置是否被使用了吗?可以使用TS对象浏览器(在模板模块中)执行此操作。是的。所有货物都完好无损…:在TS对象浏览器中,module.yourext的值是正确的,而不仅仅是plugin.yourext?您使用哪种类型的3版本?我用一个全新的扩展测试了配置,它适用于我的4.5.27版本