TYPO3: Extbase/Fluid im BE Modul

Backend Modul, erstellt mit Extbase und Fluid Templates – ohne viel Bla-Bla:

ext_tables.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
    'TYPO3.' . $_EXTKEY,
    'tools',
    'tx_myext_m1',
    '',
    array(
        'Backend' => 'migrate',
    ),
    array(
        'access' => 'user, group',
        'icon' => 'EXT:my_ext/ext_icon.gif',
        'labels' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang_mod.xml',
    )
);

locallang_mod.xml

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
    <meta type="array">
        <type>module</type>
        <description>Language labels for BE Module</description>
    </meta>
    <data type="array">
        <languageKey index="default" type="array">
            <label index="mlang_tabs_tab">My module</label>
            <label index="mlang_labels_tabdescr"></label>
        </languageKey>
    </data>
</T3locallang>

ext_typoscript_setup.txt

module.tx_myext {
    view {
        templateRootPaths {
            0 = EXT:my_ext/Resources/Private/Templates/
        }
        partialRootPaths {
            0 = EXT:my_ext/Resources/Private/Partials/
        }
        layoutRootPaths {
            0 = EXT:my_ext/Resources/Private/Layouts/
        }
    }
    settings {
        // your TypoScript setup for backend module
    }
}

Resources/Private/Templates/Backend/Migrate.html

<f:layout name="Backend"/>
 
<f:section name="main">
    <h2>Migrate Service Centers</h2>
    <f:flashMessages renderMode="div" />
 
    <f:form action="migrate" name="migrate">
        <f:form.submit name="submit" value="Migrate!" />
    </f:form>
</f:section>

Resources/Private/Layouts/Backend.html

<f:be.container>
    <div class="typo3-fullDoc">
        <div id="typo3-docheader">
            <div id="typo3-docheader-row1">
                <div class="buttonsleft">
                </div>
                <div class="buttonsright">
                    <f:be.buttons.shortcut />
                </div>
            </div>
            <div id="typo3-docheader-row2">
                <div class="docheader-row2-left">
                    <f:be.buttons.csh />
                    <f:be.menus.actionMenu>
                        <f:be.menus.actionMenuItem label="Action 1" controller="Backend" action="action1" />
                        <f:be.menus.actionMenuItem label="Action 2" controller="Backend" action="action2" />
                    </f:be.menus.actionMenu>
                </div>
                <div class="docheader-row2-right">
                    <f:be.pagePath />
                    <f:be.pageInfo />
                </div>
            </div>
        </div>
        <div id="typo3-docbody">
            <div id="typo3-inner-docbody">
                <f:render section="main" />
            </div>
        </div>
    </div>
</f:be.container>

 Classes/Controller/BackendController.php

namespace TYPO3\MyExt\Controller;
class BackendController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
    // TypoScript settings
    protected $settings = array();
    // id of selected page
    protected $id;
    // info of selected page
    protected $pageinfo;
 
    protected function initializeAction() {
        $this->id = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
        $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $GLOBALS['BE_USER']->getPagePermsClause(1));
 
        $configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager::class);
 
        $this->settings = $configurationManager->getConfiguration(
            $this->request->getControllerExtensionName(),
            $this->request->getPluginName()
        );
    }
 
    /**
     * action
     *
     * @return void
     */
    public function migrateAction() {
        $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
        $migrateRepository = $objectManager->get(\Vendor\MyExt\Domain\Repository\MigrateRepository::class);
 
        // form submitted
        if($this->request->hasArgument('submit')) {...}
 
        // add value to view
        $this->view->assign('var', 'value');
 
        // display message
        $this->addFlashMessage(
            'Some text',
            'The title',
            \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
        );
    }
}

CSS/JS Datei einlesen

<f:be.container addCssFile="{f:uri.resource(path:'path/to/file.css')}" addJsFile="{f:uri.resource(path:'path/to/file.js')}">...</f:be.container>

Fragen?

Autor:
Geändert: Mittwoch, 17. Mai 2017 11:19 Uhr
Erstellt: Dienstag, 18. Februar 2014 15:34 Uhr
Tags: , , , , , ,
Themengebiet: Web Entwicklung, TYPO3, TYPO3 Extension-Programmierung

Trackback: Trackback-URL LoadingZu Favoriten hinzufügen

Ein Kommentar

  1. 1

    […] ein Backend Modul mit Extbase/Fluid erstellt und dort auch ein Menü anbietet, kann man in diesem Artikel […]

Kommentar abgeben