Typo3 Extensions mit FlexForms: Unterschied zwischen den Versionen
| (14 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
| + | == Benötigte Dateien == | ||
Man braucht: | Man braucht: | ||
# Änderungen in ''ext_tables.php'' | # Änderungen in ''ext_tables.php'' | ||
| Zeile 4: | Zeile 5: | ||
## In der Datei wird im Abschnitt Label auf die Datei: locallang_db.xml verwiesen. In dieser wiederum werden die anderen Sprachen definiert. | ## In der Datei wird im Abschnitt Label auf die Datei: locallang_db.xml verwiesen. In dieser wiederum werden die anderen Sprachen definiert. | ||
| + | === ext_tables.php: FlexForm einblenden === | ||
Beispiel ext_tables.php (Ausschnitt): | Beispiel ext_tables.php (Ausschnitt): | ||
<pre> | <pre> | ||
| − | # Vor jeder Änderung im TCA Bereich im Frontend muß er auch geladen sein... | + | # Vor jeder Änderung im TCA Bereich im Frontend muß er auch geladen sein...(von EM Manager schon angelegt) |
t3lib_div::loadTCA('tt_content'); | t3lib_div::loadTCA('tt_content'); | ||
| + | </pre> | ||
| + | Jetzt kommts... | ||
| + | <pre> | ||
# Wir nutzen FlexForms - deshalb blenden wir die Standard-Felder layout, select_key pages und recursive aus... | # Wir nutzen FlexForms - deshalb blenden wir die Standard-Felder layout, select_key pages und recursive aus... | ||
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi1']='layout,select_key,pages,recursive'; | $TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi1']='layout,select_key,pages,recursive'; | ||
| − | # Dafür blenden wir das tt_content- | + | # Dafür blenden wir das tt_content-Feld pi_flexform ein |
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pi1']='pi_flexform'; | $TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pi1']='pi_flexform'; | ||
# Nun die Datei angeben in der das Flexform-Schema definiert ist... | # Nun die Datei angeben in der das Flexform-Schema definiert ist... | ||
| − | t3lib_extMgm::addPiFlexFormValue($_EXTKEY.' | + | t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pi1','FILE:EXT:'.$_EXTKEY.'/flexform_ds.xml'); |
| − | + | </pre> | |
| − | # Plugin aktivieren | + | Das wars im wesentlichen, ab hier wieder Standard... |
| + | <pre> | ||
| + | # Plugin aktivieren-dies sorgt dafür, dass das Plugin im Backend überhaupt ausgewählt werden kann (legt der EM automatisch an) | ||
t3lib_extMgm::addPlugin(array('LLL:EXT:hfwupersonal/locallang_db.xml:tt_content.list_type_pi1', $_EXTKEY.'_pi1'),'list_type'); | t3lib_extMgm::addPlugin(array('LLL:EXT:hfwupersonal/locallang_db.xml:tt_content.list_type_pi1', $_EXTKEY.'_pi1'),'list_type'); | ||
</pre> | </pre> | ||
| + | === Definition der Flexform Felder (flexform_ds.xml)=== | ||
Beispiel flexform_ds.xml | Beispiel flexform_ds.xml | ||
| + | |||
| + | Hinweis: Der Name der XML Datei kann auch anders gewählt werden. Dieser Name ist jedoch der Standardname. | ||
<pre> | <pre> | ||
| + | |||
| + | <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?> | ||
| + | <T3FlexForms> | ||
| + | <data type="array"> | ||
| + | <sDEF type="array"> | ||
| + | <lDEF type="array"> | ||
| + | <inputName type="array"> | ||
| + | <vDEF>Beispielwort</vDEF> | ||
| + | </inputName> | ||
| + | <inputTransformation type="array"> | ||
| + | <vDEF>lowercase</vDEF> | ||
| + | </inputTransformation> | ||
| + | </lDEF> | ||
| + | </sDEF> | ||
| + | </data> | ||
| + | </T3FlexForms> | ||
| + | |||
| + | |||
| + | </pre> | ||
| + | Innerhalb von sheets stehen die Tabs, sDEF ist das aktuelle Sheet. | ||
| + | |||
| + | == Flexforms gestalten == | ||
| + | |||
| + | Ein Flexform hat folgende '''Grundstruktur''': | ||
| + | |||
| + | <pre><nowiki> | ||
| + | <T3DataStructure> | ||
| + | <meta> | ||
| + | <langDisable>1</langDisable> | ||
| + | </meta> | ||
| + | <ROOT> | ||
| + | [...formatspezifisches Element ... ] | ||
| + | <type>array</type> | ||
| + | <el> | ||
| + | <freierElementName1> | ||
| + | [ ... formatspezifisches Element ... ] | ||
| + | </freierElementName1> | ||
| + | <freierElementName2> | ||
| + | [ ... formatspezifisches Element ... ] | ||
| + | </freierElementName2> | ||
| + | </el> | ||
| + | </ROOT> | ||
| + | </T3DataStructure> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | Ein '''Beispiel mit allerlei Eingabefeldern''' könnte wie folgt aussehen. In diesem Beispiel wird für die Namen der Felder auf eine locallang_tca.php verwiesen. Man könnte die Namen der Labels aber auch einfach direkt reinschreiben. | ||
| + | |||
| + | ===Einleitender Code=== | ||
| + | <pre><nowiki> | ||
| + | <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?> | ||
<T3DataStructure> | <T3DataStructure> | ||
<sheets> | <sheets> | ||
| − | < | + | </nowiki></pre> |
| + | |||
| + | ===Das erste Sheet=== | ||
| + | Hier beginnt '''das erste Sheet''' man stellt vor den xml bezeichner gewöhnlich ein s für sheet. Das erste formspezifische Element ist der Titel des Tabs, dann kommt ein Array und das Einleitende el Tag indem alle Elemente des Tabs gespeichert sind. | ||
| + | <pre><nowiki> | ||
| + | <sInputs> | ||
<ROOT> | <ROOT> | ||
| − | + | <TCEforms> | |
| − | + | <sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetInputs</sheetTitle> | |
| − | + | </TCEforms> | |
| − | + | <type>array</type> | |
| + | <el> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Eingabefeld=== | ||
| + | <pre><nowiki> | ||
| + | <exampleString> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleString.label</label> | ||
| + | <config> | ||
| + | <type>input</type> | ||
| + | <size>24</size> | ||
| + | <max>48</max> | ||
| + | <eval>trim</eval> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleString> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Datumsfeld=== | ||
| + | <pre><nowiki> | ||
| + | <exampleDate> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleDate.label</label> | ||
| + | <config> | ||
| + | <type>input</type> | ||
| + | <size>8</size> | ||
| + | <eval>date</eval> | ||
| + | <max>20</max> | ||
| + | <checkbox>1</checkbox> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleDate> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Ein Textfeld=== | ||
| + | <pre><nowiki> | ||
| + | <exampleArea> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleArea.label</label> | ||
| + | <config> | ||
| + | <type>text</type> | ||
| + | <cols>24</cols> | ||
| + | <rows>3</rows> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleArea> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | Ein '''Textfeld mit abgeschaltetem Zeilenumbruch''' für Code | ||
| + | <pre><nowiki> | ||
| + | <exampleCode> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleCode.label</label> | ||
| + | <config> | ||
| + | <type>text</type> | ||
| + | <cols>35</cols> | ||
| + | <rows>8</rows> | ||
| + | <wrap>off</wrap> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleCode> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Das erste Blatt ist fertig=== | ||
| + | <pre><nowiki> | ||
| + | </el> | ||
| + | </ROOT> | ||
| + | </sInputs> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===RTE=== | ||
| + | Das nächste Blatt enthält einen '''RTE'''... | ||
| + | <pre><nowiki> | ||
| + | <sRTE> | ||
| + | <ROOT> | ||
| + | <TCEforms> | ||
| + | <sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetRTE</sheetTitle> | ||
| + | </TCEforms> | ||
| + | <type>array</type> | ||
| + | <el> | ||
| + | <exampleRTE> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRTE.label</label> | ||
| + | <config> | ||
| + | <type>text</type> | ||
| + | <cols>52</cols> | ||
| + | <rows>5</rows> | ||
| + | </config> | ||
| + | <defaultExtras>richtext[*]:rte_transform[mode=ts_css]</defaultExtras> | ||
| + | </TCEforms> | ||
| + | </exampleRTE> | ||
| + | </el> | ||
| + | </ROOT> | ||
| + | </sRTE> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Auswahlfelder=== | ||
| + | Das nächste Blatt enthält Beispiele für '''Auswahlfelder'''... | ||
| + | <pre><nowiki> | ||
| + | <sSelections> | ||
| + | <ROOT> | ||
| + | <TCEforms> | ||
| + | <sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetSelections</sheetTitle> | ||
| + | </TCEforms> | ||
| + | <type>array</type> | ||
| + | <el> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Ein einfaches Select Feld=== | ||
| + | Zu beachten ist hierbei, daß der Tag numIndex index="0" den Namen(oder das Label) des Optionspunktes enthält, index="1" dagegen den key, also den später nutzbaren Wert. | ||
| + | <pre><nowiki> | ||
| + | <exampleSelection> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label</label> | ||
| + | <config> | ||
| + | <type>select</type> | ||
| + | <items type="array"> | ||
| + | <numIndex index="0" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label1</numIndex> | ||
| + | <numIndex index="1">key1</numIndex> | ||
| + | </numIndex> | ||
| + | <numIndex index="1" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label2</numIndex> | ||
| + | <numIndex index="1">key2</numIndex> | ||
| + | </numIndex> | ||
| + | <numIndex index="3" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label3</numIndex> | ||
| + | <numIndex index="1">key3</numIndex> | ||
| + | </numIndex> | ||
| + | </items> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleSelection> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Mehrfachauswahl=== | ||
| + | <pre><nowiki> | ||
| + | <exampleMultiselection> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label</label> | ||
| + | <config> | ||
| + | <type>select</type> | ||
| + | <items type="array"> | ||
| + | <numIndex index="0" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label1</numIndex> | ||
| + | <numIndex index="1">key1</numIndex> | ||
| + | </numIndex> | ||
| + | <numIndex index="1" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label2</numIndex> | ||
| + | <numIndex index="1">key2</numIndex> | ||
| + | </numIndex> | ||
| + | <numIndex index="3" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label3</numIndex> | ||
| + | <numIndex index="1">key3</numIndex> | ||
| + | </numIndex> | ||
| + | </items> | ||
| + | <maxitems>3</maxitems> | ||
| + | <size>3</size> | ||
| + | <multiple>1</multiple> | ||
| + | <selectedListStyle>width:150px</selectedListStyle> | ||
| + | <itemListStyle>width:150px</itemListStyle> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleMultiselection> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Ein Seitenbrowser=== | ||
| + | <pre><nowiki> | ||
| + | <examplePagebrowser> | ||
| + | <TCEforms> | ||
| + | <exclude>1</exclude> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.examplePagebrowser.label</label> | ||
| + | <config> | ||
| + | <type>group</type> | ||
| + | <internal_type>db</internal_type> | ||
| + | <allowed>pages</allowed> | ||
| + | <size>3</size> | ||
| + | <maxitems>22</maxitems> | ||
| + | <minitems>0</minitems> | ||
| + | <show_thumbs>1</show_thumbs> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </examplePagebrowser> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Ein Dateibrowser=== | ||
| + | <pre><nowiki> | ||
| + | <exampleFilebrowser> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleFilebrowser.label</label> | ||
| + | <config> | ||
| + | <type>group</type> | ||
| + | <internal_type>file</internal_type> | ||
| + | <allowed>tmpl,html</allowed> | ||
| + | <max_size>100</max_size> | ||
| + | <uploadfolder>uploads/</uploadfolder> | ||
| + | <maxitems>1</maxitems> | ||
| + | <size>1</size> | ||
| + | <selectedListStyle>Width:180px</selectedListStyle> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleFilebrowser> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Eine Checkbox=== | ||
| + | <pre><nowiki> | ||
| + | <exampleCheckbox> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleCheckbox.label</label> | ||
| + | <config> | ||
| + | <type>check</type> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleCheckbox> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Radio Buttons=== | ||
| + | <pre><nowiki> | ||
| + | <exampleRadio> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label</label> | ||
| + | <config> | ||
| + | <type>radio</type> | ||
| + | <items type="array"> | ||
| + | <numIndex index="0" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label1</numIndex> | ||
| + | <numIndex index="1">key1</numIndex> | ||
| + | </numIndex> | ||
| + | <numIndex index="1" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label2</numIndex> | ||
| + | <numIndex index="1">key2</numIndex> | ||
| + | </numIndex> | ||
| + | <numIndex index="3" type="array"> | ||
| + | <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label3</numIndex> | ||
| + | <numIndex index="1">key3</numIndex> | ||
| + | </numIndex> | ||
| + | </items> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleRadio> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Ende des Sheets=== | ||
| + | <pre><nowiki> | ||
| + | </el> | ||
| + | </ROOT> | ||
| + | </sSelections> | ||
| + | </nowiki></pre> | ||
| + | Auswahlfelder können Ihre Werte auch dynamisch aus der Datenbank beziehen, darum gehts im nächsten Sheet | ||
| + | <pre><nowiki> | ||
| + | <sDynamics> | ||
| + | <ROOT> | ||
| + | <TCEforms> | ||
| + | <sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetDynamics</sheetTitle> | ||
| + | </TCEforms> | ||
| + | <type>array</type> | ||
| + | <el> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===Ein dynamisches Select Feld=== | ||
| + | mit Werten aus der Tabelle static_template | ||
| + | <pre><nowiki> | ||
| + | <exampleQuery> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleQuery.label</label> | ||
| + | <config> | ||
| + | <type>select</type> | ||
| + | <items> | ||
| + | <numIndex index="0"> | ||
| + | <numIndex index="0">--</numIndex> | ||
| + | <numIndex index="1">0</numIndex> | ||
| + | </numIndex> | ||
| + | </items> | ||
| + | <foreign_table>static_template</foreign_table> | ||
| + | <foreign_table_where> | ||
| + | AND static_template.uid < 30 | ||
| + | </foreign_table_where> | ||
| + | <size>1</size> | ||
| + | <minitems>0</minitems> | ||
| + | <maxitems>1</maxitems> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleQuery> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | Eine '''Funktion''' kann ebenfalls genutzt werden um die WErte bereitzustellen | ||
| + | <pre><nowiki> | ||
| + | <exampleFunction> | ||
| + | <TCEforms> | ||
| + | <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleFunction.label</label> | ||
| + | <config> | ||
| + | <type>select</type> | ||
| + | <items> | ||
| + | <numIndex index="0"> | ||
| + | <numIndex index="0">--</numIndex> | ||
| + | <numIndex index="1">0</numIndex> | ||
| + | </numIndex> | ||
| + | </items> | ||
| + | <itemsProcFunc>tx_sbflexamples_itemFunctions->exampleFunction</itemsProcFunc> | ||
| + | </config> | ||
| + | </TCEforms> | ||
| + | </exampleFunction> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | ===XML-Struktur beenden=== | ||
| + | Das letzte '''Sheet fertigstellen'''... | ||
| + | <pre><nowiki> | ||
| + | |||
| + | </el> | ||
| + | </ROOT> | ||
| + | </sDynamics> | ||
| + | </nowiki></pre> | ||
| + | |||
| + | Die komplette '''Struktur beenden''' | ||
| + | <pre><nowiki> | ||
| + | </sheets> | ||
| + | </T3DataStructure> | ||
| + | |||
| + | </nowiki></pre> | ||
| + | |||
| + | |||
| + | ===Labels übersetzen - Sprachdatei=== | ||
| + | Der Vollständigkeit halber ein Auszug aus der locallang_tca.php in der die Sprachlabels definiert werden: | ||
| + | |||
| + | <?php | ||
| + | <pre> | ||
| + | $LOCAL_LANG = Array ( | ||
| + | 'default' => Array ( | ||
| + | ... | ||
| + | 'hfwupersonal.pi_flexform.sheetSelections' => 'Selections', | ||
| + | 'hfwupersonal.pi_flexform.sheetDynamics' => 'Dynamic Selections', | ||
| + | 'hfwupersonal.pi_flexform.exampleDate.label' => 'Date', | ||
| + | ... | ||
| + | ), | ||
| + | 'de' => Array ( | ||
| + | ... | ||
| + | 'hfwupersonal.pi_flexform.sheetSelections' => 'Statische Auswahlfelder', | ||
| + | 'hfwupersonal.pi_flexform.sheetDynamics' => 'Dynamische Auswahlfelder', | ||
| + | 'hfwupersonal.pi_flexform.exampleDate.label' => 'Datum', | ||
| + | ... | ||
| + | ), | ||
| + | ); | ||
| + | ?> | ||
| + | |||
</pre> | </pre> | ||
| − | + | ||
| + | == Auf Flexform-Daten zugreifen == | ||
| + | Um die Daten aus dem Flexform zu verarbeiten nutzen wir Funktionen der '''tslib_pibase'''. Die Daten befinden sich als '''XML-String''' in | ||
| + | |||
| + | ''$this->cObj->data['pi_flexform']'' | ||
| + | Um den Zugriff zu vereinfachen gibt es eine Funktion die den Inhalt in ein Array rendert: | ||
| + | |||
| + | $this->pi_initPIflexForm(); | ||
| + | |||
| + | jetzt steht ein Array in $this->cObj->data['pi_flexform'] zur Verfügung. Darauf könnte man jetzt schon gut zugreifen. Besonders leicht geht es aber mit der Funktion: | ||
| + | |||
| + | function pi_getFFvalue($T3FlexForm_array,$fieldName,$sheet='sDEF,$lang='lDEF',$value='vDEF'); | ||
| + | |||
| + | Beispiel: | ||
| + | |||
| + | $myName = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'inputName'); | ||
| + | |||
| + | In diesem Fall wäre ''$sheet'',''$lang'' und ''$value'' mit den Defaultwerten benannt (siehe XML-Beispiel), deshalb müssen Sie nicht übergeben werden. | ||
Aktuelle Version vom 2. Dezember 2008, 05:51 Uhr
Benötigte Dateien[Bearbeiten]
Man braucht:
- Änderungen in ext_tables.php
- Die Datei flexform_ds.xml. In dieser befindet sich der XML code den Typo3 nutzt um das Flexform zu generieren.
- In der Datei wird im Abschnitt Label auf die Datei: locallang_db.xml verwiesen. In dieser wiederum werden die anderen Sprachen definiert.
ext_tables.php: FlexForm einblenden[Bearbeiten]
Beispiel ext_tables.php (Ausschnitt):
# Vor jeder Änderung im TCA Bereich im Frontend muß er auch geladen sein...(von EM Manager schon angelegt)
t3lib_div::loadTCA('tt_content');
Jetzt kommts...
# Wir nutzen FlexForms - deshalb blenden wir die Standard-Felder layout, select_key pages und recursive aus... $TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi1']='layout,select_key,pages,recursive'; # Dafür blenden wir das tt_content-Feld pi_flexform ein $TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pi1']='pi_flexform'; # Nun die Datei angeben in der das Flexform-Schema definiert ist... t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pi1','FILE:EXT:'.$_EXTKEY.'/flexform_ds.xml');
Das wars im wesentlichen, ab hier wieder Standard...
# Plugin aktivieren-dies sorgt dafür, dass das Plugin im Backend überhaupt ausgewählt werden kann (legt der EM automatisch an)
t3lib_extMgm::addPlugin(array('LLL:EXT:hfwupersonal/locallang_db.xml:tt_content.list_type_pi1', $_EXTKEY.'_pi1'),'list_type');
Definition der Flexform Felder (flexform_ds.xml)[Bearbeiten]
Beispiel flexform_ds.xml
Hinweis: Der Name der XML Datei kann auch anders gewählt werden. Dieser Name ist jedoch der Standardname.
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<T3FlexForms>
<data type="array">
<sDEF type="array">
<lDEF type="array">
<inputName type="array">
<vDEF>Beispielwort</vDEF>
</inputName>
<inputTransformation type="array">
<vDEF>lowercase</vDEF>
</inputTransformation>
</lDEF>
</sDEF>
</data>
</T3FlexForms>
Innerhalb von sheets stehen die Tabs, sDEF ist das aktuelle Sheet.
Flexforms gestalten[Bearbeiten]
Ein Flexform hat folgende Grundstruktur:
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<ROOT>
[...formatspezifisches Element ... ]
<type>array</type>
<el>
<freierElementName1>
[ ... formatspezifisches Element ... ]
</freierElementName1>
<freierElementName2>
[ ... formatspezifisches Element ... ]
</freierElementName2>
</el>
</ROOT>
</T3DataStructure>
Ein Beispiel mit allerlei Eingabefeldern könnte wie folgt aussehen. In diesem Beispiel wird für die Namen der Felder auf eine locallang_tca.php verwiesen. Man könnte die Namen der Labels aber auch einfach direkt reinschreiben.
Einleitender Code[Bearbeiten]
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?> <T3DataStructure> <sheets>
Das erste Sheet[Bearbeiten]
Hier beginnt das erste Sheet man stellt vor den xml bezeichner gewöhnlich ein s für sheet. Das erste formspezifische Element ist der Titel des Tabs, dann kommt ein Array und das Einleitende el Tag indem alle Elemente des Tabs gespeichert sind.
<sInputs>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetInputs</sheetTitle>
</TCEforms>
<type>array</type>
<el>
Eingabefeld[Bearbeiten]
<exampleString> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleString.label</label> <config> <type>input</type> <size>24</size> <max>48</max> <eval>trim</eval> </config> </TCEforms> </exampleString>
Datumsfeld[Bearbeiten]
<exampleDate> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleDate.label</label> <config> <type>input</type> <size>8</size> <eval>date</eval> <max>20</max> <checkbox>1</checkbox> </config> </TCEforms> </exampleDate>
Ein Textfeld[Bearbeiten]
<exampleArea> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleArea.label</label> <config> <type>text</type> <cols>24</cols> <rows>3</rows> </config> </TCEforms> </exampleArea>
Ein Textfeld mit abgeschaltetem Zeilenumbruch für Code
<exampleCode> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleCode.label</label> <config> <type>text</type> <cols>35</cols> <rows>8</rows> <wrap>off</wrap> </config> </TCEforms> </exampleCode>
Das erste Blatt ist fertig[Bearbeiten]
</el>
</ROOT>
</sInputs>
RTE[Bearbeiten]
Das nächste Blatt enthält einen RTE...
<sRTE>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetRTE</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<exampleRTE>
<TCEforms>
<label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRTE.label</label>
<config>
<type>text</type>
<cols>52</cols>
<rows>5</rows>
</config>
<defaultExtras>richtext[*]:rte_transform[mode=ts_css]</defaultExtras>
</TCEforms>
</exampleRTE>
</el>
</ROOT>
</sRTE>
Auswahlfelder[Bearbeiten]
Das nächste Blatt enthält Beispiele für Auswahlfelder...
<sSelections>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetSelections</sheetTitle>
</TCEforms>
<type>array</type>
<el>
Ein einfaches Select Feld[Bearbeiten]
Zu beachten ist hierbei, daß der Tag numIndex index="0" den Namen(oder das Label) des Optionspunktes enthält, index="1" dagegen den key, also den später nutzbaren Wert.
<exampleSelection> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label</label> <config> <type>select</type> <items type="array"> <numIndex index="0" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label1</numIndex> <numIndex index="1">key1</numIndex> </numIndex> <numIndex index="1" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label2</numIndex> <numIndex index="1">key2</numIndex> </numIndex> <numIndex index="3" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleSelection.label3</numIndex> <numIndex index="1">key3</numIndex> </numIndex> </items> </config> </TCEforms> </exampleSelection>
Mehrfachauswahl[Bearbeiten]
<exampleMultiselection> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label</label> <config> <type>select</type> <items type="array"> <numIndex index="0" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label1</numIndex> <numIndex index="1">key1</numIndex> </numIndex> <numIndex index="1" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label2</numIndex> <numIndex index="1">key2</numIndex> </numIndex> <numIndex index="3" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleMultiselection.label3</numIndex> <numIndex index="1">key3</numIndex> </numIndex> </items> <maxitems>3</maxitems> <size>3</size> <multiple>1</multiple> <selectedListStyle>width:150px</selectedListStyle> <itemListStyle>width:150px</itemListStyle> </config> </TCEforms> </exampleMultiselection>
Ein Seitenbrowser[Bearbeiten]
<examplePagebrowser> <TCEforms> <exclude>1</exclude> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.examplePagebrowser.label</label> <config> <type>group</type> <internal_type>db</internal_type> <allowed>pages</allowed> <size>3</size> <maxitems>22</maxitems> <minitems>0</minitems> <show_thumbs>1</show_thumbs> </config> </TCEforms> </examplePagebrowser>
Ein Dateibrowser[Bearbeiten]
<exampleFilebrowser> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleFilebrowser.label</label> <config> <type>group</type> <internal_type>file</internal_type> <allowed>tmpl,html</allowed> <max_size>100</max_size> <uploadfolder>uploads/</uploadfolder> <maxitems>1</maxitems> <size>1</size> <selectedListStyle>Width:180px</selectedListStyle> </config> </TCEforms> </exampleFilebrowser>
Eine Checkbox[Bearbeiten]
<exampleCheckbox> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleCheckbox.label</label> <config> <type>check</type> </config> </TCEforms> </exampleCheckbox>
Radio Buttons[Bearbeiten]
<exampleRadio> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label</label> <config> <type>radio</type> <items type="array"> <numIndex index="0" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label1</numIndex> <numIndex index="1">key1</numIndex> </numIndex> <numIndex index="1" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label2</numIndex> <numIndex index="1">key2</numIndex> </numIndex> <numIndex index="3" type="array"> <numIndex index="0">LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleRadio.label3</numIndex> <numIndex index="1">key3</numIndex> </numIndex> </items> </config> </TCEforms> </exampleRadio>
Ende des Sheets[Bearbeiten]
</el>
</ROOT>
</sSelections>
Auswahlfelder können Ihre Werte auch dynamisch aus der Datenbank beziehen, darum gehts im nächsten Sheet
<sDynamics>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetDynamics</sheetTitle>
</TCEforms>
<type>array</type>
<el>
Ein dynamisches Select Feld[Bearbeiten]
mit Werten aus der Tabelle static_template
<exampleQuery> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleQuery.label</label> <config> <type>select</type> <items> <numIndex index="0"> <numIndex index="0">--</numIndex> <numIndex index="1">0</numIndex> </numIndex> </items> <foreign_table>static_template</foreign_table> <foreign_table_where> AND static_template.uid < 30 </foreign_table_where> <size>1</size> <minitems>0</minitems> <maxitems>1</maxitems> </config> </TCEforms> </exampleQuery>
Eine Funktion kann ebenfalls genutzt werden um die WErte bereitzustellen
<exampleFunction> <TCEforms> <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleFunction.label</label> <config> <type>select</type> <items> <numIndex index="0"> <numIndex index="0">--</numIndex> <numIndex index="1">0</numIndex> </numIndex> </items> <itemsProcFunc>tx_sbflexamples_itemFunctions->exampleFunction</itemsProcFunc> </config> </TCEforms> </exampleFunction>
XML-Struktur beenden[Bearbeiten]
Das letzte Sheet fertigstellen...
</el>
</ROOT>
</sDynamics>
Die komplette Struktur beenden
</sheets> </T3DataStructure>
Labels übersetzen - Sprachdatei[Bearbeiten]
Der Vollständigkeit halber ein Auszug aus der locallang_tca.php in der die Sprachlabels definiert werden:
<?php
$LOCAL_LANG = Array ( 'default' => Array ( ... 'hfwupersonal.pi_flexform.sheetSelections' => 'Selections', 'hfwupersonal.pi_flexform.sheetDynamics' => 'Dynamic Selections', 'hfwupersonal.pi_flexform.exampleDate.label' => 'Date', ... ), 'de' => Array ( ... 'hfwupersonal.pi_flexform.sheetSelections' => 'Statische Auswahlfelder', 'hfwupersonal.pi_flexform.sheetDynamics' => 'Dynamische Auswahlfelder', 'hfwupersonal.pi_flexform.exampleDate.label' => 'Datum', ... ), ); ?>
Auf Flexform-Daten zugreifen[Bearbeiten]
Um die Daten aus dem Flexform zu verarbeiten nutzen wir Funktionen der tslib_pibase. Die Daten befinden sich als XML-String in
$this->cObj->data['pi_flexform'] Um den Zugriff zu vereinfachen gibt es eine Funktion die den Inhalt in ein Array rendert:
$this->pi_initPIflexForm();
jetzt steht ein Array in $this->cObj->data['pi_flexform'] zur Verfügung. Darauf könnte man jetzt schon gut zugreifen. Besonders leicht geht es aber mit der Funktion:
function pi_getFFvalue($T3FlexForm_array,$fieldName,$sheet='sDEF,$lang='lDEF',$value='vDEF');
Beispiel:
$myName = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'inputName');
In diesem Fall wäre $sheet,$lang und $value mit den Defaultwerten benannt (siehe XML-Beispiel), deshalb müssen Sie nicht übergeben werden.