Typo3 Extensions entwickeln @deprecated: Unterschied zwischen den Versionen

Aus Vosp.info
Wechseln zu:Navigation, Suche
(templates nutzen)
(templates nutzen)
Zeile 29: Zeile 29:
 
  // ....
 
  // ....
 
  public function main($content, array $conf) {
 
  public function main($content, array $conf) {
  $this->conf = $conf;
+
  // speichern der Konfiguration
 +
$this->conf = $conf;
 +
// POST GET wird geladen
 
  $this->pi_setPiVarDefaults();
 
  $this->pi_setPiVarDefaults();
 +
// Sprachdaten werden geladen
 
  $this->pi_loadLL();
 
  $this->pi_loadLL();
 
    
 
    
 +
// css wird included
 
  $GLOBALS['TSFE']->pSetup['includeCSS.'][$this->extKey] = 'EXT:' . $this->extKey . '/pi1/css/template.css';
 
  $GLOBALS['TSFE']->pSetup['includeCSS.'][$this->extKey] = 'EXT:' . $this->extKey . '/pi1/css/template.css';
+
 
 +
// template wird included
 
  $this->template = $this->cObj->fileResource('EXT:' . $this->extKey . '/pi1/templates/template.html');
 
  $this->template = $this->cObj->fileResource('EXT:' . $this->extKey . '/pi1/templates/template.html');
 
   
 
   
 +
// Subparts werden extrahiert
 
  $tmpl_SUBPART1 = $this->cObj->getSubpart($this->template, '###SUBPART1###');
 
  $tmpl_SUBPART1 = $this->cObj->getSubpart($this->template, '###SUBPART1###');
 
  $tmpl_SUBPART2 = $this->cObj->getSubpart($this->template, '###SUBPART2###');
 
  $tmpl_SUBPART2 = $this->cObj->getSubpart($this->template, '###SUBPART2###');
 
   
 
   
 +
// Werte werden für die Marker gesetzt
 
  $array_markers = array(
 
  $array_markers = array(
 
  '###VAR1###' => 'Var1',
 
  '###VAR1###' => 'Var1',
Zeile 45: Zeile 52:
 
  );
 
  );
 
   
 
   
 +
// der Subpart 2 wird ins SUBPART2_MARKER gesetzt
 
  $array_markers['###SUBPART2_MARKER###'] = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART2, $array_markers);
 
  $array_markers['###SUBPART2_MARKER###'] = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART2, $array_markers);
 
   
 
   
 +
//
 
  $content = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART1, $array_markers);
 
  $content = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART1, $array_markers);
 
   
 
   

Version vom 16. Februar 2013, 17:15 Uhr

Typo3

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

tslib_pibase

templates nutzen

pi1/templates/template.html

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

<!-- ###SUBPART2### begin -->
	<div ID="VAR2">###VAR2###</div>
<!-- ###SUBPART2### end -->

pi1/template.css

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

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

class tx_testit_pi1 extends tslib_pibase {
	// ....
	public function main($content, array $conf) {
		// speichern der Konfiguration 

$this->conf = $conf;

		// POST GET wird geladen
		$this->pi_setPiVarDefaults();
		// Sprachdaten werden geladen
		$this->pi_loadLL(); 		
 
		// css wird included
		$GLOBALS['TSFE']->pSetup['includeCSS.'][$this->extKey] = 'EXT:' . $this->extKey . '/pi1/css/template.css';
 
		// template wird included
		$this->template = $this->cObj->fileResource('EXT:' . $this->extKey . '/pi1/templates/template.html');

		// Subparts werden extrahiert
		$tmpl_SUBPART1 = $this->cObj->getSubpart($this->template, '###SUBPART1###');
		$tmpl_SUBPART2 = $this->cObj->getSubpart($this->template, '###SUBPART2###');

		// Werte werden für die Marker gesetzt
		$array_markers = array(
			'###VAR1###' => 'Var1',
			'###VAR2###' => 'Var2',
		);

		// der Subpart 2 wird ins SUBPART2_MARKER gesetzt
		$array_markers['###SUBPART2_MARKER###'] = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART2, $array_markers);

		// 
		$content = $this->cObj->substituteMarkerArrayCached($tmpl_SUBPART1, $array_markers);

		return $this->pi_wrapInBaseClass($content);
	}
	// ....
}