Flexform Konfiguration in ein Array auslesen
Okt 21
CMS, Typo3 Array, Flexform, Hint, hinweis, php, Quellcode, Typo3 Keine Kommentare
Um in TYPO3 ein Plugin zu erstellen mit diversen Konfigurationsmöglichkeiten (ohne TypoScript) benötigt man ein sogenanntes Flexform. Diese Datei ist eine XML mit bestimmten Aufbau. Um im eigenen Plugin nun auf diese Werte zurückzugreifen muss zuerst das Flexform mittels $this->pi_initPIflexForm(); initialisiert werden anschließend kann jeder Wert mit der Funktion $this->pi_getFFvalue($this->cObj->data["pi_flexform"], "what_to_display") abgefragt werden.
Ziemlich viele Zeichen sind dafür nötig, deshalb gibt es ein kleines Snippet welches alle Konifgurationen aus dem Flexform in ein Array (lConf) ausliest.
-
-
$this->pi_initPIflexForm(); // Init and get the flexform data of the plugin
-
// Assign the flexform data to a local variable for easier access
-
$piFlexForm = $this->cObj->data[‘pi_flexform’];
-
// Traverse the entire array based on the language…
-
// and assign each configuration option to $this->lConf array…
-
foreach ( $piFlexForm[‘data’] as $sheet => $data ) {
-
foreach ( $data as $lang => $value ) {
-
foreach ( $value as $key => $val ) {
-
$this->lConf[$key] = $this->pi_getFFvalue($piFlexForm, $key, $sheet);
-
}
-
}
-
}
Wie das ganze genau funktioniert, kann hier nachgelesen werden.
RSS
Twitter