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.

  1.  
  2. $this->pi_initPIflexForm(); // Init and get the flexform data of the plugin
  3. $this->lConf = array(); // Setup our storage array…
  4.     // Assign the flexform data to a local variable for easier access
  5.     $piFlexForm = $this->cObj->data[‘pi_flexform’];
  6.     // Traverse the entire array based on the language…
  7.     // and assign each configuration option to $this->lConf array…
  8.     foreach ( $piFlexForm[‘data’] as $sheet => $data ) {
  9.         foreach ( $data as $lang => $value ) {
  10.             foreach ( $value as $key => $val ) {
  11.                 $this->lConf[$key] = $this->pi_getFFvalue($piFlexForm, $key, $sheet);
  12.             }
  13.         }
  14.     }

Wie das ganze genau funktioniert, kann hier nachgelesen werden.

Ähnliche Beiträge