Display full hierarchy for taxonomy metadata #283

This commit is contained in:
leogermani 2019-07-29 11:40:29 -03:00
parent 8fa75006be
commit 5ed051103e
1 changed files with 18 additions and 1 deletions

View File

@ -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();