[TYPO3-german] Suche Funktion: array2subpart

Stefan Frömken firma at sfroemken.de
Fri Jul 22 19:06:50 CEST 2011


Ich werkel mittlerweile 5 Stunden an dieser Funktion rum. Es 
funktioniert noch nicht so wie ich will. Grrr:

	function array2subpart(&$content, $xml, $key = '') {
		echo "<p>Start</p>";
		if(is_array($xml)) {
			echo "<p>Ist Array</p>";
			foreach($xml as $key => $value) {
				$key = ltrim($key, '@'); // This is for @attributes
				if(is_array($value)) {
					$content = $this->cObj->getSubpart($this->templateCode, '###' . 
strtoupper($key) . '###');
					echo "<p>Loop Array: Key: " . $key . "<br />" . $content . "</p>";
				}
				self::array2subpart($content, $value, $key);
			}
		} else {
			$content = $this->cObj->substituteMarker($content, '###' . 
strtoupper($key) . '###', $xml);
			$this->templateCode = 
$this->cObj->substituteSubpart($this->templateCode, '###' . 
strtoupper($key) . '###', $content);
			echo "<p>Ist String. Key: " . $key . " : String: " . $content . "</p>";
		}
		return $content;
	}

vcmrdkl var

Am 22.07.2011 18:07, schrieb Stefan Frömken:
> Hallo zusammen,
>
> ich bin zwar ein Fan von sich selbst aufrufenden Funktionen, aber selbst
> so ein Konstrukt umzusetzen gestaltet sich wohl doch schwieriger als
> erwartet.
>
> Ich habe ein multidimensionales Array und will alle Keys, die ein Array
> enthalten als Subpart im Template zur Verfügung stellen und alle Strings
> in diesem Array mit substituteMarkerArray in das entsprechende Subpart
> einbinden.
>
> Sehr kleines Beispiel. multiArray:
>
> Array(
> anbieter => array(
> anbieternr => 123,
> wohnung => array(
> adresse => strasse 123,
> plz => 12345
> )
> )
> )
>
> Folgender Templateaufbau:
> <!-- ###ANBIETER### begin -->
> <div>###ANBIETERNR###</div>
> <!-- ###WOHNUNG### begin -->
> <ul>
> <li>###ADRESSE###</li>
> <li>###PLZ###</li>
> </ul>
> <!-- ###WOHNUNG### end -->
> <!-- ###ANBIETER### end -->
>
> Ein Link, ein Lösungsansatz bzw. einen Tritt in die richtige Richtung
> würde mir schon helfen.
>
> Danke Euch
>
> Stefan



More information about the TYPO3-german mailing list