Typo3 Extensions entwickeln @deprecated: Unterschied zwischen den Versionen

Aus Vosp.info
Wechseln zu:Navigation, Suche
(Konfiguration mit Flexforms)
(Software mit php)
Zeile 115: Zeile 115:
 
=== Software mit php ===
 
=== Software mit php ===
 
'''pi1/class.tx_testit_pi1.php (bzw. die Hauptklasse)'''
 
'''pi1/class.tx_testit_pi1.php (bzw. die Hauptklasse)'''
<source lang="php">
+
 
 +
<source lang="php" line="GESHI_NORMAL_LINE_NUMBERS">
 
<?php
 
<?php
 
  class tx_testit_pi1 extends tslib_pibase {
 
  class tx_testit_pi1 extends tslib_pibase {

Version vom 16. Februar 2013, 21:58 Uhr

Typo3

um sich das Grundgerüst einer Extension erstellen zu lassen bitte hier schauen Typo3 kickstarter Extension

tslib_pibase

Beispiel mit template, css und Sprachdatei

template mit html

pi1/templates/template.html

 <!-- ###SUBPART1### begin -->
 	<div ID="VAR1">###VAR1###</div> 
 	<div ID="SUBPART2_MARKER">###SUBPART2_MARKER###</div>
 	<div ID="VAR_CONF">###VAR_CONF###</div> 
 <!-- ###SUBPART1### end -->
 
 <!-- ###SUBPART2### begin -->
 	<div ID="VAR2">###VAR2###</div>
 <!-- ###SUBPART2### end -->

Design mit css

pi1/template.css

 div#VAR1 {
 	font-size: 12px;	color:red;
 }
 div#VAR2 {
 	font-size: 14px;	color:blue;
 }
 div#VAR_CONF{
 	font-size: 16px;	color:green;
 }

Lokalisierung mit xml

pi1/locallang.xml

 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <T3locallang>
 	<meta type="array">
 		<type>module</type>
 		<description>Language labels for plugin &quot;tx_testit_pi1&quot;</description>
 	</meta>
 	<data type="array">
 		<languageKey index="default" type="array">
 			<label index="VAR1">text for var 1 in english</label>
 			<label index="VAR2">text for var 2 in english</label>
 		</languageKey>
 		<languageKey index="de" type="array">
 			<label index="VAR1">Text für var 1 in deutsch</label>
 			<label index="VAR2">Text für var 2 in deutsch</label>
 		</languageKey>
 	</data>
 </T3locallang>

Konfiguration mit Flexforms

pi/flexform_ds_pi1.xml

 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <T3DataStructure>
    <sheets>
        <Konfigurationsformular>
            <ROOT>
                <TCEforms>
                    <sheetTitle>LLL:EXT:testit/locallang_db.xml:tt_content.list_type_pi1</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <VAR_CONF_Formular>
                        <TCEforms>
                            <label>LLL:EXT:testit/locallang_db.xml:VAR_CONF</label>
                            <config>
                                <type>input</type>
                                <size>100</size>
                            </config>
                        </TCEforms> 
                    </VAR_CONF_Formular>
                 </el>
             </ROOT>
         </Konfigurationsformular>
     </sheets>
 </T3DataStructure>

locallang_db.xml

 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <T3locallang>
 	<meta type="array">
 		<type>database</type>
 		<description>Language labels for database tables/fields belonging to extension 'testit'</description>
 	</meta>
 	<data type="array">
 		<languageKey index="default" type="array">
 			<label index="tt_content.list_type_pi1">testit title</label>
 			<label index="VAR_CONF">please set a value for the frontend</label>
 		</languageKey>
 		<languageKey index="de" type="array">
 			<label index="tt_content.list_type_pi1">testit Title</label>
 			<label index="VAR_CONF">bitte einen Wert fürs Frontend setzen</label>
 		</languageKey>
 	</data>
 </T3locallang>

ext_tables.php folgende Zeilen hinzufügen

<?
 // ....
 $TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pi1']='pi_flexform';
 t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pi1', 'FILE:EXT:'.$_EXTKEY.'/pi1/flexform_ds_pi1.xml');
?>

Software mit php

pi1/class.tx_testit_pi1.php (bzw. die Hauptklasse)

 1 <?php
 2  class tx_testit_pi1 extends tslib_pibase {
 3  	// ....
 4  	public function main($content, array $conf) {
 5  		// speichern der Konfiguration 
 6  		$this->conf = $conf;
 7  		// POST GET wird geladen
 8  		$this->pi_setPiVarDefaults();
 9  		// Sprachdaten werden geladen
10  		$this->pi_loadLL(); 		
11   
12  		// css wird included
13  		$GLOBALS['TSFE']->pSetup['includeCSS.'][$this->extKey] = 'EXT:' . $this->extKey . '/pi1/css/template.css';
14   
15  		// template wird included
16  		$this->template = $this->cObj->fileResource('EXT:' . $this->extKey . '/pi1/templates/template.html');
17  
18  		// Subparts werden extrahiert
19  		$tmpl_SUBPART1 = $this->cObj->getSubpart($this->template, '###SUBPART1###');
20  		$tmpl_SUBPART2 = $this->cObj->getSubpart($this->template, '###SUBPART2###');
21  
22  		//   Flexform laden
23  		$this->pi_initPIflexForm();
24  
25  		// Werte werden für die Marker gesetzt
26  		$array_markers = array(
27  			'###VAR1###' => $this->pi_getLL('VAR1'),
28  			'###VAR2###' => $this->pi_getLL('VAR2'),
29  			'###VAR_CONF###' => $this->pi_getFFvalue($this->cObj->data['pi_flexform'], "VAR_CONF_Formular", "Konfigurationsformular"),
30  		);
31  
32  		// der Subpart 2 wird ins SUBPART2_MARKER gesetzt
33  		$array_markers['###SUBPART2_MARKER###'] = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART2, $array_markers);
34  
35  		// 
36  		$content = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART1, $array_markers);
37  
38  		return $this->pi_wrapInBaseClass($content);
39  	}
40  	// ....
41  }
42 ?>