Typo3 Extensions mit FlexForms

Aus Wikizone
Wechseln zu: Navigation, Suche

Man braucht:

  1. Änderungen in ext_tables.php
  2. Die Datei flexform_ds.xml. In dieser befindet sich der XML code den Typo3 nutzt um das Flexform zu generieren.
    1. In der Datei wird im Abschnitt Label auf die Datei: locallang_db.xml verwiesen. In dieser wiederum werden die anderen Sprachen definiert.

Beispiel ext_tables.php (Ausschnitt):

# Vor jeder Änderung im TCA Bereich im Frontend muß er auch geladen sein...
t3lib_div::loadTCA('tt_content');
# 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-Felod 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_de.xml');

# 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');

Beispiel flexform_ds.xml


<?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

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 so aussehen:

<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<T3DataStructure>
  <sheets>
    <sInputs>
      <ROOT>
	<TCEforms>
	  <sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetInputs</sheetTitle>
	</TCEforms>
	<type>array</type>
	<el>
	  <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>
	  <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>
	  <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>
	  <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>
	</el>
      </ROOT>
    </sInputs>
    <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>
    <sSelections>    
      <ROOT>
	<TCEforms>
	  <sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetSelections</sheetTitle>
	</TCEforms>
	<type>array</type>
	<el>
	  <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>	
	  <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>
x		<size>3</size>
		<multiple>1</multiple>
		<selectedListStyle>width:150px</selectedListStyle>
		<itemListStyle>width:150px</itemListStyle>
	      </config>
	    </TCEforms>
	  </exampleMultiselection>
	  <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>
	  <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>
	  <exampleCheckbox>
	    <TCEforms>
	      <label>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.exampleCheckbox.label</label>
	      <config>
		<type>check</type>
	      </config>
	    </TCEforms>
	  </exampleCheckbox>
	  <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>
	</el>
      </ROOT>      
    </sSelections>
    <sDynamics>    
      <ROOT>
	<TCEforms>
	  <sheetTitle>LLL:EXT:sb_flexamples/locallang_tca.php:sb_flexamples.pi_flexform.sheetDynamics</sheetTitle>
	</TCEforms>
	<type>array</type>
	<el>
	  <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>
	  <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>
	</el>
      </ROOT>      
    </sDynamics>
  </sheets>
</T3DataStructure>