Zum Inhalt springen

Template problem :(

Erstellt am 27. August 2007 · 2 Antworten · letzte Antwort am 27. August 2007

Tags: Frage

THE_AI ·

Hallo zusammen!
Ich schreibe gerade eine Extension und soweit läuft es, aber das Template macht mir Probleme.
So sieht es aus:

<!-- ###TEMPLATE_CATEGORY### -->

	<!--- ###ITEMS### begin--->
<table border="1">
<tr>
	<td>###MAINCATEGORY###</td>
	<td>###SUBCATEGORY###</td>
</tr>
</table>
	<!--- ###ITEMS### --->

<!-- ###TEMPLATE_CATEGORY### end -->

In meiner PHP Datei mache ich folgendes:

$template = $this->cObj->fileResource('EXT:ab/template/ab.html');

		$t = array ();
		$t['total'] = $this->cObj->getSubpart($template, "###TEMPLATE_CATEGORY###");
		$t['item'] = $this->cObj->getSubpart($template, "###ITEMS###");
		$subpartArray = array (
			'###ITEMS###' => ''
		);

		$fieldmain = 'bezeichnung,uid';
		$tablemain = 'ab AS a';
		$wheremain = 'a.parent_category = 0';

//		$GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true;
		$resmain = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fieldmain,$tablemain,$wheremain);
//		echo $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;




		while($rowmain = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resmain)) {

			$markerArray['###MAINCATEGORY###'] = $rowmain['bezeichnung'];

			$wheresub = 'a.parent_category='.$rowmain['uid'];
			$ressub = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fieldmain,$tablemain,$wheresub);

			if ($ressub){
				$markerArray['###SUBCATEGORY###'] = '';
				while($rowsub = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($ressub)){
					$markerArray['###SUBCATEGORY###'] .= $rowsub['bezeichnung'];
				}

			}
			$subpartArray['###ITEMS###'] = $this->cObj->substituteMarkerArray($t['item'], $markerArray);
			$content .= $this->cObj->substituteMarkerArrayCached($t['total'], $markerArray, $subpartArray);

		}

Das funktioniert, aber nicht so wie ich es will.
Anstatt einer Tabelle mit den Daten der Datenbank - bekomme ich für jede Maincategory eine Taballe. z.B.

<table>
<tr><td>maincategory1</td><td>subcategories 1 2 3 4</td></tr>
</table>
und dann:
<table>
<tr><td>maincategory2</td><td>subcategories 5 6 7 8</td></tr>
</table>

und ich möchte es so haben:

<table>
<tr><td>maincategory1</td><td>subcategories 1 2 3 4</td></tr>
<tr><td>maincategory2</td><td>subcategories 1 2 3 4</td></tr>
</table>

Ich habe es so mit anderen Extentions gemacht und es hat funktioniert, aber dies mal nicht mehr 🙁
Auf einem Tipp wäre ich sehr dankbar.

MichaMore ·

Hallo The_AI,

müsste das Template bei Dir nicht so aussehen:

<!-- ###TEMPLATE_CATEGORY### -->

<table border="1">
	<!--- ###ITEMS### begin--->
<tr>
	<td>###MAINCATEGORY###</td>
	<td>###SUBCATEGORY###</td>
</tr>
	<!--- ###ITEMS### --->
</table>

<!-- ###TEMPLATE_CATEGORY### end -->

Auf den ersten Blick erstellst du nämlich sonst über das Ansprechen von ###ITEMS### jedes Mal eine neue Tabelle. Wenn du ###ITEMS### innerhalb der Tabelle aufrufst und nur immer eine neue Zeile anlegst, müsste das doch klappen, wie du willst.

Viele Grüße
Michael

THE_AI ·

Menschenskinder! Das war's!

Ich bin so Doof und habe das selbst nicht gesehen 😢

Danke für die Hilfe!!!

P.S. und

$subpartArray['###ITEMS###'] = $this->cObj->substituteMarkerArray($t['item'], $markerArray);
$content .= $this->cObj->substituteMarkerArrayCached($t['total'], $markerArray, $subpartArray);

muss auf:

$subpartArray['###ITEMS###'] .= $this->cObj->substituteMarkerArray($t['item'], $markerArray);
$content = $this->cObj->substituteMarkerArrayCached($t['total'], $markerArray, $subpartArray);

geändert werden 🙂