Display full hierarchy for taxonomy metadata #283
This commit is contained in:
parent
8fa75006be
commit
5ed051103e
|
@ -220,7 +220,7 @@ class Taxonomy extends Metadata_Type {
|
|||
if ( $term instanceof \Tainacan\Entities\Term ) {
|
||||
$return .= $prefix;
|
||||
|
||||
$return .= $term->_toHtml();
|
||||
$return .= $this->get_term_hierarchy_html($term);
|
||||
|
||||
$return .= $suffix;
|
||||
|
||||
|
@ -244,6 +244,23 @@ class Taxonomy extends Metadata_Type {
|
|||
|
||||
}
|
||||
|
||||
private function get_term_hierarchy_html( \Tainacan\Entities\Term $term ) {
|
||||
|
||||
$terms = [];
|
||||
|
||||
$terms[] = $term->_toHtml();
|
||||
|
||||
while ($term->get_parent() > 0) {
|
||||
$term = \Tainacan\Repositories\Terms::get_instance()->fetch( (int) $term->get_parent(), $term->get_taxonomy() );
|
||||
$terms[] = $term->_toHtml();
|
||||
}
|
||||
|
||||
$terms = \array_reverse($terms);
|
||||
|
||||
return \implode(' > ', $terms);
|
||||
|
||||
}
|
||||
|
||||
public function _toArray() {
|
||||
|
||||
$array = parent::_toArray();
|
||||
|
|
Loading…
Reference in New Issue