Cześć,
żeby zrobić takie drzewko możesz iteracyjne przelecieć po kolekcji wyciągniętej z bazy i wyświetlić tylko te elementy które Cię interesują.
Tu masz opisane jeśli nie czytałeś:
- drzewko NestedSet :
http://www.doctrine-project.org/api/orm/1...._nestedset.html - tutaj pojedynczy węzeł drzewka:
http://www.doctrine-project.org/api/orm/1...._nestedset.htmlMusisz znać kliknięty węzeł (node) i jego porównujesz odpowiedni do kolejnych węzłów w foreachu.
Poniżej podaję przykład wyświetlenia takiego drzewka w pętli (dla potrzeb przykładu nie jest zrefaktorowane

):
foreach($tree as $node){
$display = false;
if($element->isDescendantOf($node->getRawValue())) // jeśli node jest parentem elementu
{
$parent_table[$node->getLevel()] = $node;
$display = true;
}
elseif($node->isDescendantOfOrEqualTo($element->getRawValue()) && $node->getLevel()-1 <= $element->getLevel()) // jeśli node jestem samym soba lub bezpośrednim dzieckiem
{
$display = true;
}
elseif(isset($parent_table[$node->getLevel()-1
]) && $parent_table[$node->getLevel()-1
]->isParent($node->getRawValue())) // jesli jego rodzic znajduje się w tablicy otwartych nodów {
$display = true;
}
if($display){
for($i = 0; $i <= $node->getLevel(); $i++)
{
}
echo $node->getName() . '<br/>'; }
}
Element drzewka musi mieć następujące metody:
public function isDescendantOf(Element $subj)
{
return (($this->getLft() > $subj->getLft()) &&
($this->getRgt() < $subj->getRgt()) &&
($this->getRootId() == $subj->getRootId()));
}
public function isDescendantOfOrEqualTo(Element $subj)
{
return (($this->getLft() >= $subj->getLft()) &&
($this->getRgt() <= $subj->getRgt()) &&
($this->getRootId() == $subj->getRootId()));
}
public function isParent(Element $subj)
{
return (($this->getLft() < $subj->getLft()) &&
($this->getRgt() > $subj->getRgt()) &&
($this->getLevel() == $subj->getLevel()-1));
}
P.S. Podaj więcej szczegółów odnośnie tego jak będziesz i gdzie używał drzewka bo może inny sposób jest lepszy (css/js)