---
title: "Viewhelper im Viewhelper (For each=\"viewhelper\")?"
url: "https://www.typo3.net/d/109396-viewhelper-im-viewhelper-for-eachviewhelper"
source: "typo3.net"
tags: ["Extensions","Extbase","Fluid","Frage","ViewHelper"]
created: "2012-02-15"
last_reply: "2012-02-15"
replies: 0
solved: false
page: 1
pages: 1
lang: "de"
---

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

Extensions › Extbase · 0 Antworten · gestartet 2012-02-15

## Eröffnungsbeitrag

**at_lightwerk.​com** · 2012-02-15 · [Beitrag #1](https://www.typo3.net/d/109396-viewhelper-im-viewhelper-for-eachviewhelper/1)

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:

```php
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**

```html
<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?

---

Quelle: „Viewhelper im Viewhelper (For each="viewhelper")?“, typo3.net, https://www.typo3.net/d/109396-viewhelper-im-viewhelper-for-eachviewhelper
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
