Zum Inhalt springen

Frontendausgabe, aber wie?

Erstellt am 22. April 2007 · 4 Antworten · letzte Antwort am 23. April 2007

Tags: Templates & Layouts, PHP, Frage

kruemelchen26 ·

Hallo Leute,

ich habe mir eine Extension geschrieben, bzw. bin noch dabei. Das Frontend funktioniert soweit mit der Ausgabe, nur die Form der Ausgabe gefällt mir nicht.

Die Ausgabe der Ergebnisse erfolgt untereinander.
Beispiel:

1 - Nominat
2 - Morph1
3 - Morph2
4 - Morph3

Nun möchte ich diese jedoch so haben, das ich 3 Ergebnisse nebeneinander und das es dann in einer neuen Zeile losgeht.

Beispiel:

1 - Nominat 2 - Morph1 2 - Morph2
4 - Morph3

rein in PHP wüsste ich wie es hinbekommen würde, aber hier bei meiner Extension leider nicht und wollte ich daher um ein paar Tipps bitten. Anbei mal noch die Funktion und das Template, es handelt sich dabei um die 2. while Schleife.

Grüße Marko

function displayAll() {
		
		# Get the parts out of the template
		$template = array();
		$template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE###');
		$template['reptile'] = $this->cObj->getSubpart($template['total'],'###REPTILES###');
		$query_species = "SELECT * FROM tx_mhreptiles_species";
    $res_species = mysql(TYPO3_db,$query_species);
    while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_species)) {
    	
    	$content_reptile = '';
		 	$markerArray['###MARKER_SPECIES###'] = $row['species'];             
			$query_reptiles = "SELECT * FROM tx_mhreptiles_reptiles WHERE species=".$row['uid']." order by species,subspecies";
    	$res_reptiles = mysql(TYPO3_db,$query_reptiles);
    	
    	while ($row_reptiles = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_reptiles)) {
	      
	      $markerArray["###MARKER_SUBSPECIES###"] = $this->getFieldContent('subspecies',$row_reptiles['subspecies']);
	      $markerArray["###MARKER_REPTILES_NAME###"] = $row_reptiles['name'];
	      $markerArray["###MARKER_REPTILES_IMAGE###"] = $this->getFieldContent('image',$row_reptiles['image']);
	      $markerArray["###MARKER_REPTILES_PRICE_FEMALE###"] = $row_reptiles['pricefemale'];
	      $markerArray["###MARKER_REPTILES_PRICE_MALE###"] = $row_reptiles['pricemale'];
	      $content_reptile .= $this->cObj->substituteMarkerArrayCached($template['reptile'], $markerArray);
	    
	    }
	    
	    $subpartArray['###CONTENT###'] = $content_reptile; 
			$content .= $this->cObj->substituteMarkerArrayCached($template['total'], $markerArray, $subpartArray, $wrappedSubpartContentArray);
			
		}
		
    return $content;
    
	}
<!-- ###TEMPLATE### begin -->
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
	<td align="left"><font face="Tahoma, Verdana, Arial" style="font-size: 11pt; font-weight: bold;">###MARKER_SPECIES###</font></td>
</tr>
<tr>
	<td align="left">###MARKER_SUBSPECIES###</td>
</tr>
<!-- ###CONTENT### -->
	<!-- ###REPTILES### -->
		<tr>
			<td align="left" width="25%">
				<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr valign="top">
						<td align="center" colspan="2">###MARKER_REPTILES_NAME###</td>
					</tr>
					<tr valign="top">
						<td align="center" colspan="2">###MARKER_REPTILES_IMAGE###</td>
					</tr>
					<tr valign="top">
						<td align="left" width="50%">Preis Weibchen:</td>
						<td align="right" width="50%">###MARKER_REPTILES_PRICE_FEMALE###</td>
					</tr>
					<tr valign="top">
						<td align="left" width="50%">Preis Männchen:</td>
						<td align="right" width="50%">###MARKER_REPTILES_PRICE_MALE###</td>
					</tr>
				</table>
			</td>
		</tr>
	<!-- ###REPTILES### -->
<!-- ###CONTENT### -->
</table>
<!-- ###TEMPLATE### end -->
just2b ·

Hallo Marko,

lass in der Schleife ne Variable bis 4 Zählen und schreib dann das in einen anderen subpart

$content_reptile2 .= $this->cObj->substituteMarkerArrayCached($template['reptile2'], $markerArray);

, den du dann danach dranhängst...

nur mal eine Idee, vielleicht gings auch eleganter

georg

kruemelchen26 ·

Hallo georg,

dann müsste ich aber mein Template um reptile2 erweitern oder nicht?
Das mit eine Variable hochzählen habe ich auch schon versucht jedoch nicht hinbekommen. Könntest Du mir da ggf. ein Bsp. zu nennen?

Grüße Marko

jenses ·
kruemelchen26 schrieb

... rein in PHP wüsste ich wie es hinbekommen würde ...

kruemelchen26 schrieb

Das mit eine Variable hochzählen habe ich auch schon versucht jedoch nicht hinbekommen. Könntest Du mir da ggf. ein Bsp. zu nennen?

Hmmh, ich sehe da irgendwie Widersprüche 8-)
PHP für Dummies

kruemelchen26 ·

hmm...habe nochmal dran gearbeitet und das mit der Variable eingefügt und jetzt läuft es. Keine Ahnung warum es gestern nicht ging.

function displayAll() {
		
		# Get the parts out of the template
		$template = array();
		$template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE###');
		$template['reptile'] = $this->cObj->getSubpart($template['total'],'###REPTILES###');
		$query_species = "SELECT * FROM tx_mhreptiles_species WHERE deleted='0' AND hidden='0'";
    $res_species = mysql(TYPO3_db,$query_species);
    while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_species)) {
    	
    	$content_reptile = '';
		 	$markerArray['###MARKER_SPECIES###'] = $row['species'];             
			$query_reptiles = "SELECT * FROM tx_mhreptiles_reptiles WHERE species=".$row['uid']." AND deleted='0' AND hidden='0' order by species,subspecies";
    	$res_reptiles = mysql(TYPO3_db,$query_reptiles);

    	while ($row_reptiles = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_reptiles)) {
				if(!$i) { $markerArray["###MARKER_TR_START###"] = '<tr>'; }
				else { $markerArray["###MARKER_TR_START###"] = ''; }
				$i++;
				
	      $markerArray["###MARKER_SUBSPECIES###"] = $this->getFieldContent('subspecies',$row_reptiles['subspecies']);
	      $markerArray["###MARKER_REPTILES_NAME###"] = $row_reptiles['name'];
	      $markerArray["###MARKER_REPTILES_IMAGE###"] = $this->getFieldContent('image',$row_reptiles['image']);
	      $markerArray["###MARKER_REPTILES_PRICE_FEMALE###"] = $row_reptiles['pricefemale'];
	      $markerArray["###MARKER_REPTILES_PRICE_MALE###"] = $row_reptiles['pricemale'];
	      
	      if($i == 3) { $markerArray["###MARKER_TR_END###"] = '</tr>'; unset($i); }
	      else { $markerArray["###MARKER_TR_END###"] = ''; }
	      
	      $content_reptile .= $this->cObj->substituteMarkerArrayCached($template['reptile'], $markerArray);
	    
	    }
	    
	    $subpartArray['###CONTENT###'] = $content_reptile; 
			$content .= $this->cObj->substituteMarkerArrayCached($template['total'], $markerArray, $subpartArray, $wrappedSubpartContentArray);
			
		}
		
    return $content;
    
	}