[TYPO3-mvc] How to solve "Duplicate variable declarations!"

Henjo Hoeksma me at henjohoeksma.nl
Sun Jul 17 17:27:39 CEST 2011


Hi list,

for a category structure I created a forViewhelper that gives all the 
objects back that have the uid of the parents set.

Fluid:
<c:categoryTree category="{category.uid}" as="subcategory">

ViewHelper:
    /**
     *
     * @param integer $category
     * @param string $as The name of the iteration variable
     * @return string
     */
    public function render($category,$as) {
	$categoryRepository = 
t3lib_div::makeInstance('Tx_Peproducts_Domain_Repository_CategoryRepository'); 
// Singleton
	$categories = $categoryRepository->findByParent($category);
	foreach($categories as $keyValue => $value){
	    $this->templateVariableContainer->add($as, $value);
	    $this->templateVariableContainer->add($key, $keyValue);
	    $output .= $this->renderChildren();
	    $this->templateVariableContainer->remove($as);
	    $this->templateVariableContainer->remove($key);
	}
	return $output;
    }

For one layer this works perfect. I want to add an extra sublayer like this:
<c:categoryTree category="{category.uid}" as="subcategory">
	{subcategory.uid}
	   <c:categoryTree category="{subcategory.uid}" as="subsubcategory">
		{subsubcategory.uid}
	   </c:categoryTree>
</c:categoryTree>

This results in a "Duplicate variable declarations!" error.
I tried to modify the viewhelper to also give back child categories, to 
no avail.

Can somebody point me in the good direction? I'm kinda stuck here :-(

Thanks in advance.

Henjo



More information about the TYPO3-project-typo3v4mvc mailing list