TYPO3 Extbase backend module. Template path issue

蹲街弑〆低调 提交于 2019-12-05 21:37:57

Try to clean all caches, even in typo3temp/Core/Cache (or something like that)

The main problem will be that the typoscript configurations will not get loaded on storage folders or pages without an template in the root path.

Explaination: typoscript configuration you will set for your extension wether it is in ext_typoscript_setup, an static template or via php it will always need an system record template somewhere in the root of the page. otherwise it will not get rendered - and no path settings for your extbase extensions will happen, so the default layout, template and partial path is set and thats the place the script will look for your stuff.

Default is:

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

if you need to override these for your backendmodule you can work around that problem by injecting the settings for the view directly in your controller.

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

}

}

i hope this helps greetz benji

As @benjamin-kott explains, TYPO3's backend modules configurations need to be loaded first. Unfortunately, extension's typoscript files are not automatically loaded by default.

One way of make TYPO3 aware of this typoscript files is creating two files in extension's root folder:

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

(kind of obvious but: you should replace this paths with yours)

After adding this files, you should reinstall the extension to see changes. You can use the TypoScript Object Browser to find out if your setup and constants are being loaded.

freshp

I dont realy know ur setup, but normaly you must setup these paths in /Configuration/TypoScript/setup.txt like this

module.tx_yourext {
    persistence {
        storagePid = {$pid}
    }
    view {
        templateRootPath = {$templateRootPath}
        partialRootPath = {$partialRootPath}
        layoutRootPath = {$layoutRootPath}
    }
}

This configuration does not being used until you add the static template of your extension. Also you should add these lines to the 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',
        )
    );
}

Although this thread is quite old I want to show you guys my solution for TYPO3 7.6 LTS.

First you need to include your TypoScript files via Template > Edit whole record > Includes.

And in your TypoScript you need to use templateRootPaths.0 instead of 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/
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!