// Get ancestors list
$ancestors = array_keys( $node->getAncestors() ); // cached version of ancestors()->get()
// Shift dummy one
array_shift( $ancestors );
$path = [];
$categories = static::getCategories(); // cached version of Model_Category::forge()->roots()->get_one()->dump_tree( TRUE );
foreach ( $ancestors as $i )
{
$ancestor = $categories[ $i ] ?? FALSE;
if ( $ancestor )
{
$anchorAttr = [];
$categories = $ancestor->children;
$path .= '<li><a href="/c/' . $ancestor->id . '-' . $ancestor->name_seo . '">' . $ancestor->name . '</a>';
}
}
What do you think about this approach? Could this be done any better?
It looks like you're new here. If you want to get involved, click one of these buttons!