Closed LordSimal closed 2 years ago
Do you have an idea for a fix as PR?
I haven't doven into your recursive function yet 😅
The warning can easily be fixed with a isset()
but the printed HTML is not correct.
Left is with
echo $this->Tree->generate( $categories, [
'element' => 'categorie_tree',
'type' => 'div',
'itemType' => 'div'
] );
Right is with
echo $this->Tree->generate( $categories, [
'element' => 'categorie_tree',
//'type' => 'div',
'itemType' => 'div'
] );
I usually used a callback directly, or method. If you find a way to make it work, though, a PR is welcome.
Well here is some more info:
with both 'type' => 'div', 'itemType' => 'div'
the functions addTypeAttribute()
and addItemAttribute()
behave differently.
addTypeAttribute
now adds the class to the item, not the wrapper around it and
addItemAttribute
doesn't do anything at all
The problem seems to be, that this condition is not good when type and itemType are both the same. https://github.com/dereuromark/cakephp-tools/blob/master/src/View/Helper/TreeHelper.php#L484
It seems like I got a fix. I will create a PR
When outputting
I get the error
Its not that big of a deal but I would prefer simple divs with custom classes (which are set in my element) instead of a ul-li structure.
My element template is
CakePHP 4.2.10 Plugin Version: 2.3.0