Php – TYPO3 Extbase backend module. Template path issue

content-management-systemextbasepathPHPtypo3

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

Best Answer

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

Related Topic