Zum Inhalt springen

Viewhelper im Viewhelper (For each="viewhelper")?

Erstellt am 15. Februar 2012 · Noch keine Antworten

Tags: Fluid, ViewHelper, Frage

at_lightwerk.​com ·

Hi Leute,

bin fast schon am verzweifeln! 🙁

habe ein dickes Array das so aufgebaut ist
$documentations sieht so aus:
Array
(
[G] => Array
(
[0] => Array
(
[dok_doktypen_kurz] => G
[id] => 423423
[gruppen_id] => 212
)
[2] => Array
(
[dok_doktypen_kurz] => G
[id] => 324423
[gruppen_id] => 212
)
[3] => Array
(
[dok_doktypen_kurz] => G
[id] => 213213213
[gruppen_id] => 2223
)
[K] => Array
(
[0] => Array
(
[dok_doktypen_kurz] => H
[id] => 312312
[gruppen_id] => 433
)
[2] => Array
(
[dok_doktypen_kurz] => H
[id] => 321354
[gruppen_id] => 112
)
[3] => Array
(
[dok_doktypen_kurz] => H
[id] => 432
[gruppen_id] => 433
)

usw..
Und hab dann noch ein Array das doc_doctypes_name, aber das spielt grad keine Rolle.

Problem ist das fluid das hier nicht kann -> {documentations.{docLabel}}
{documentations} ist das obige array.
{docLabel} ist im obigen Array die Buchstaben also der erste Key. In unserem Beispiel ist das "G" und "H" wie ihr seht.

So sieht mein Viewhelper aus:

class Tx_LwSewDocumentation_ViewHelpers_DoctypeViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {

	/**
	 * Chooses the value of an Array by the given String
	 *
	 * @param mixed $associativeArray
	 * @param mixed $key
	 * @author Aleksandar Todorovic
	 */

	public function render($associativeArray, $key) {
		$docs = $associativeArray[$key];
		echo "<pre>";print_r($associativeArray);
			if($docs['sprache'] == "de-DE"){
				if (is_array($docs)) {

					return $docs;
				}

		}
	}


}

So sieht die Fluid datei aus:

Nun will ich das Ergebnis aus dem viewhelper weiterverwenden undzwar in der For schleife die unten steht, da ich im viewhelper das Array returne, das ich benötige fĂŒr die nĂ€chste foreach schleife

<document:doctype associativeArray="{documentations}" key="G" > <!-- hier steht eigentlich dann das array {docLabel} ansatt "G" -->
		<f:for each="{document:doctype(associativeArray: '{documentations}', key: 'G')}" as="doctype" key="label">

Wieso funkt das nicht?