3

I'm experiencing a strange problem with extbase/fluid extension creation. I use TYPO3 6.1

I've made an extension with a backend module on my dev server (same configuration/hardware then the prod). The module works perfectly with the path to the template :

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

After this, I downloaded my extension's zip in the ext manager and then installer on the prod server. Now I can't use my extension because the module don't find the templates. I've configured the extension by the same way. The templates are in the right path.

I test to move my folder to the parent level :

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

With this it works, but in the module configuration, I specify the right path to the "Backend/" folder.

I wont to move my folder in the Private folder, I want it to run in the Private/Backend folder.

I've included the extension static template to the website root TS template.

Here's the constants :

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

And here's the setup :

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

5 回答 5

6

主要问题是在根路径中没有模板的存储文件夹或页面上不会加载打字稿配置。

说明: 您将为您的扩展设置打字稿配置,无论它是在 ext_typoscript_setup、静态模板还是通过 php,它总是需要在页面根部的某个位置有一个系统记录模板。否则它不会被渲染 - 并且不会发生您的 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(){

}

}

我希望这有助于greetz benji

于 2013-12-18T15:53:30.383 回答
4

正如@benjamin-kott 解释的那样,需要先加载 TYPO3 的后端模块配置。不幸的是,默认情况下不会自动加载扩展的打字稿文件。

使 TYPO3 了解此打字稿文件的一种方法是在扩展的根文件夹中创建两个文件:

  1. ext_typoscript_constants.txt

    <INCLUDE_TYPOSCRIPT: source="FILE:EXT:myext/Configuration/TypoScript/constants.txt">
    
  2. ext_typoscript_setup.txt

    <INCLUDE_TYPOSCRIPT: source="FILE:EXT:myext/Configuration/TypoScript/setup.txt">
    

(有点明显,但是:你应该用你的路径替换这个路径)

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

于 2015-11-25T08:43:13.673 回答
2

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

于 2013-12-12T14:29:23.113 回答
2

我真的不知道你的设置,但通常你必须像这样在 /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',
        )
    );
}
于 2013-05-29T07:37:14.377 回答
2

虽然这个帖子很老了,但我想向你们展示我对 TYPO3 7.6 LTS 的解决方案。

首先,您需要通过 包含您的 TypoScript 文件Template > Edit whole record > Includes

在您的 TypoScript 中,您需要使用templateRootPaths.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/
    }
}
于 2016-07-04T09:20:32.910 回答