Zum Inhalt springen

Keine Anzeige mit HTML-Template

Erstellt am 12. Dezember 2006 · Noch keine Antworten

Tags: Templates & Layouts, Frage

SirRuddy ·

Hallo,

ich habe eine Extension geschrieben die ein HTML-Template (sofern vorhanden) für die Ausgabe verwenden soll. Ich habe mich hierbei an das Video-Tutorial von Kasper Skrhj gehalten: (http://typo3.netfielders.de/fepi/fepi_10_supporting_external_html_templates.wmv). Ohne HTML-Template funktioniert die Ausgabe auch einwandfrei. Wenn ich aber via TS die Vorlage lade, erhalte ich im Quellcode nur leere <table> </table>-Tags, wo eigentlich die Tabelle mit den Platzhaltern erscheinen soll.

# HTML-Vorlage für Messekalender einbinden
plugin.tx_ksmessecal_pi1.listView.altTemplateFile = FILE
plugin.tx_ksmessecal_pi1.listView.altTemplateFile.file = fileadmin/templates/tmpl_ksmessecal.html

Naheliegend, das die Subparts nicht richtig ausgewertet werden, oder das Template nicht korrekt angesprochen wird. - Ich kann hier aber keinen Fehler entdecken. Um Euch nicht mit dem gesamten Quellcode des Kickstarters zu langweilen, habe ich mal nur die wichtigen Stellen rauskopiert.

[...]
 
         /**
         * Shows a list of database entries
         *
         * @param       string  $content: content of the PlugIn
         * @param       array    $conf: PlugIn Configuration
         * @return      HTML list of table entries
         */
        function listView($content,$conf)       {
                $this->conf=$conf;            // Setting the TypoScript passed to this function in $this->conf
                $this->pi_setPiVarDefaults();
                $this->pi_loadLL();          // Loading the LOCAL_LANG values
                $this->pi_USER_INT_obj=1;       // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
                $lConf = $this->conf['listView.'];      // Local settings for the listView function
                
                $this->templateFileContent = $this->cObj->cObjGetSingle($lConf['altTemplateFile'],$lConf['altTemplateFile']); // 
		<- Das stammt von mir! if ($this-></->
		piVars['showUid'])   {  // If a single element should be displayed:
                        $this->internal['currentTable'] = 'tx_ksmessecal_main';
                        $this->internal['currentRow'] = $this->pi_getRecord('tx_ksmessecal_main',$this->piVars['showUid']);
        
                        $content = $this->singleView($content,$conf);
                        return $content;
                } else {
                        $items=array(
                                '1'=> $this->pi_getLL('list_mode_1','Mode 1'),
                                '2'=> $this->pi_getLL('list_mode_2','Mode 2'),
                                '3'=> $this->pi_getLL('list_mode_3','Mode 3'),
 
[...]
 
/**
         * Returns a single table row for list view
         *
         * @param       integer                $c: Counter for odd / even behavior
         * @return      A HTML table row
         */
        function pi_list_row($c)        {
                $editPanel = $this->pi_getEditPanel();
                if ($editPanel) $editPanel='
		<td>'.$editPanel.'</td>
		';
                
                if ($this->templateFileContent) {
                        $dataRowContent = $this->cObj->getSubpart($this->templateFileContent, '###DATAROW'.($c%2 ? '1' : '2').'###');
                
                                $substArray=array();
                                $substArray['###MESSENAME###'] = $this->getFieldContent('messename');
                                $substArray['###MESSEANFANG###'] = $this->getFieldContent('messeanfang');
                                $substArray['###MESSEENDE###'] = $this->getFieldContent('messeende');
                                $substArray['###MESSEORT###'] = $this->getFieldContent('messeort');
                                $substArray['###EDITPANEL###'] = $editPanel;
                                
                        return $this->cObj->substituteMarkerArrayCached($dataRowContent,$substArray);
                } else { 
                        return '
		<tr'.($c%2 this-=""></tr'.($c%2>
		pi_classParam("listrow-odd") : '').'>
		<td valign="top">
			<p>'.$this->getFieldContent('messename').'</p>
		</td>
		<td valign="top">
			<p>'.$this->getFieldContent('messeanfang').'</p>
		</td>
		<td valign="top">
			<p>'.$this->getFieldContent('messeende').'</p>
		</td>
		<td valign="top">
			<p>'.$this->getFieldContent('messeort').'</p>
		</td>
		</tr>';
                }
        }
        /**
         * Returns a table row with column names of the table
         *
         * @return      A HTML table row
         */
        function pi_list_header()       {
                if ($this->templateFileContent) {
                        $headerRowContent = $this->cObj->getSubpart($this->templateFileContent, '###HEADERROW###');
                
                                $substArray=array();
                                $substArray['###MESSENAME###'] = $this->getFieldHeader_sortLink('messename');
                                $substArray['###MESSEANFANG###'] = $this->getFieldHeader_sortLink('messeanfang');
                                $substArray['###MESSEENDE###'] = $this->getFieldHeader('messeende');
                                $substArray['###MESSEORT###'] = $this->getFieldHeader('messeort');
                                
                        return $this->cObj->substituteMarkerArrayCached($headerRowContent,$substArray);
                } else {
                        return '
		<tr'.$this-></tr'.$this->
		pi_classParam('listrow-header').'>
		<td>
			<p>'.$this->getFieldHeader_sortLink('messename').'</p>
		</td>
		<td nowrap="">
			<p>'.$this->getFieldHeader_sortLink('messeanfang').'</p>
		</td>
		<td nowrap="">
			<p>'.$this->getFieldHeader('messeende').'</p>
		</td>
		<td>
			<p>'.$this->getFieldHeader('messeort').'</p>
		</td>
		</tr>';
                }
        }
        /**
         * Returns the content of a given field
         *
         * @param       string  $fN: name of table field
         * @return      Value of the field
         */
        function getFieldContent($fN)   {
                switch($fN) {
                        case 'messename':
                                return $this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1);    // The "1" means that the display of single items is CACHED! Set to zero to disable caching.
                        break;
                        case "messeanfang":
                                        // For a numbers-only date, use something like: %d-%m-%y
                                return strftime('%d.%m.%Y',$this->internal['currentRow']['messeanfang']);
                        break;
                        case "messeende":
                                        // For a numbers-only date, use something like: %d-%m-%y
                                return strftime('%d.%m.%Y',$this->internal['currentRow']['messeende']);
                        break;
                        case "messeort":
                                        // Adressen aus tt_address auslesen
                                if (!count($this->adresseCache))        {
                                        $query = 'SELECT * FROM tt_address WHERE pid='.intval($GLOBALS["TSFE"]->id).
                                                $this->cObj->enableFields('tt_address');
                                        $res = mysql(TYPO3_db,$query);
                                        while($row=mysql_fetch_assoc($res))     {
                                                $this->adresseCache[$row['uid']]=$row;
                                                }
                                        }
                                return htmlspecialchars($this->adresseCache[$this->internal['currentRow']['messeort']['city']]);
                        break;
                        default:
                                return $this->internal['currentRow'][$fN];
                        break;
                }
        }
 
[...]

Und um die Sache komplett zu machen, hier das HTML-Template welches unter fileadmin/templates/tmpl_ksmessecal.html liegt:

<!-- ###HEADERROW### anfang -->
			<tr>
				<td class="tx-ksmessecal-pi1-listrow-Header">###MESSENAME###</td>
				<td class="tx-ksmessecal-pi1-listrow-Header">###MESSEANFANG###</td>
				<td class="tx-ksmessecal-pi1-listrow-Header">###MESSEENDE###</td>
				<td class="tx-ksmessecal-pi1-listrow-Header">###MESSEORT###</td>
			</tr>
		<!-- ###HEADERROW### ende -->
		
		<!-- ###DATAROW1### anfang -->
			<tr>
				<td class="tx-ksmessecal-pi1-listrow-dataRow1">###MESSENAME###</td>
				<td class="tx-ksmessecal-pi1-listrow-dataRow1">###MESSEANFANG###</td>
				<td class="tx-ksmessecal-pi1-listrow-dataRow1">###MESSEENDE###</td>
				<td class="tx-ksmessecal-pi1-listrow-dataRow1">###MESSEORT###</td>
			</tr>
		<!-- ###DATAROW1### ende -->
		
		<!-- ###DATAROW2### anfang -->
			<tr>
				<td class="tx-ksmessecal-pi1-listrow-dataRow2">###MESSENAME###</td>
				<td class="tx-ksmessecal-pi1-listrow-dataRow2">###MESSEANFANG###</td>
				<td class="tx-ksmessecal-pi1-listrow-dataRow2">###MESSEENDE###</td>
				<td class="tx-ksmessecal-pi1-listrow-dataRow2">###MESSEORT###</td>
				###EDITPANEL###
			</tr>
		<!-- ###DATAROW2### ende -->

Über Eure Hilfe würde ich mich sehr freuen!

Gruß
SirRuddy