[TYPO3-german] TYPO3 6.2 eigenen Wizard mit Fluid template?

David Gurk dgurk at medienwerft.de
Fri Oct 16 11:27:48 CEST 2015


Also ich habe jetzt eine gangbare Lösung. Über Verbesserungsvorschläge bin ich aber dankbar.

Interessehalber fände ich es auch interessant zu wissen, ob es in TYPO3 7 eine bessere Möglichkeit gibt.

---

Bei einem Inhaltselement zum Beispiel im Flexform wurde der Wizard definiert:
<settings.feldName>
	<TCEforms>
		<label>LLL:EXT:meine_extension/Resources/Private/Language/locallang_db.xlf:inhaltselement.feldName</label>
		<config>
			<type>input</type>
			<size>20</size>
			<eval>trim</eval>
			<default>100</default>
			<wizards>
				<txMeineExtensionBackendModuleWizardName>
					<type>script</type>
					<title>Bearbeiten</title>
					<icon>add.gif</icon>
					<params></params>
					<module>
						<name>wizard_WizardName</name>
					</module>
				</txMeineExtensionBackendModuleWizardName>
			</wizards>
		</config>
	</TCEforms>
</settings.feldName>

---

In ext_tables.php das Module für den Wizard definieren:
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
	'wizard_WizardName',
	\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/Wizards/BaseHomepageMainSlide/'
);

---

Folgende Dateien anlegen:
Für TYPO3s "mod.php" unter typo3conf/ext/meine_extension/Modules/Wizards/WizardName/conf.php
<?php
$MCONF['name'] = 'wizard_WizardName';
$MCONF['script'] = '_DISPATCH';
$MCONF['access'] = '';

--

Die eigentliche Magie, um Extbase zu starten unter typo3conf/ext/meine_extension/Modules/Wizards/WizardName/index.php
<?php
$configuration = array(
	'vendorName' => 'MeinVendor',
	'extensionName' => 'MeineExtension',
	'pluginName' => 'Wizard',
);

/** @var \TYPO3\CMS\Extbase\Core\Bootstrap $bootstrap */
$bootstrap = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Core\\Bootstrap');
$content = $bootstrap->run('', $configuration);
print $content;

---

In ext_localconf.php die "switchableControllerActions" manuell definieren, weil kein eigentliches Plugin für den Wizard existiert:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MeineExtension']['modules']['Wizard']['controllers'] = array(
	'Wizard' => array(
		'actions' => array(
			'wizardName', 'close'
		)
	)
);

---

<?php

namespace MeinVendor\MeineExtension\Controller;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\HttpUtility;

class WizardController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
	/**
	 * @var array parameters
	 */
	public $P;

	public function initializeAction() {
		// On init call
		$this->P = GeneralUtility::_GP('P');

		// After
		if($this->request->hasArgument('P')) {
			$this->P = $this->request->getArgument('P');
		}
	}

	/**
	 * @return void
	 */
	public function wizardNameAction() {
		$this->view->assignMultiple(array(
			'P' => $this->P,
		));
	}

	/**
	 * Return to the previous content element where the wizard is opened from
	 *
	 * @return void
	 */
	public function closeAction() {
		HttpUtility::redirect(GeneralUtility::sanitizeLocalUrl($this->P['returnUrl']));
	}
}

---

Template passend zum Controller anlegen typo3conf/ext/meine_extension/Resources/Private/Templates/Wizard/WizardName.html
<f:be.container
		enableClickMenu="0"
		loadPrototype="0"
		loadScriptaculous="0"
		loadExtJs="0"
		loadExtJsTheme="0"
		includeCssFiles="{0: '{f:uri.resource(path: \'Stylesheets/Wizard/WizardName.css\')}'}"
		loadJQuery="1"
		includeJsFiles="{0: '{f:uri.resource(path: \'JavaScript/Wizard/WizardName.js\')}'}"
		>
	<f:form arguments="{P: P}" name="wizardForm">
		<div class="typo3-fullDoc">
			<div id="typo3-docheader">
				<div class="typo3-docheader-functions">
					<div class="left"></div>
					<div class="right"></div>
				</div>
				<div class="typo3-docheader-buttons">
					<div class="left">
						<f:be.buttons.icon uri="{f:uri.action(action: 'close', arguments: {P: P})}" icon="actions-document-close" title="Close" />
						<f:be.buttons.icon uri="javascript:document.wizardForm.submit()" icon="actions-document-save-close" title="Save and close" />
					</div>
				</div>
			</div>
			<div id="typo3-docbody">
				<div id="typo3-inner-docbody">
					Magic goes here
				</div>
			</div>
		</div>
	</f:form>
</f:be.container>

---


More information about the TYPO3-german mailing list