FEATURE Refactoring and optimizing admin columns for thematiques
This commit is contained in:
parent
6f277c7c83
commit
12a3af83ed
|
|
@ -270,6 +270,46 @@ function build_page_chapter_index($blocks)
|
||||||
return $chapterBlockIndex;
|
return $chapterBlockIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------
|
||||||
|
GET ALL THEMATIQUES ORGANIZED BY PARENTS
|
||||||
|
---------------------------------------------*/
|
||||||
|
function getAllThematiquesTermsByParents()
|
||||||
|
{
|
||||||
|
// Récupérer tous les termes de la taxonomie 'thematiques' avec une hiérarchie
|
||||||
|
$ThematiquesTerms = get_terms([
|
||||||
|
'taxonomy' => 'thematiques',
|
||||||
|
'orderby' => 'name',
|
||||||
|
'order' => 'ASC',
|
||||||
|
'hide_empty' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$terms_by_parent = [];
|
||||||
|
$child_terms = [];
|
||||||
|
|
||||||
|
if ($ThematiquesTerms) {
|
||||||
|
|
||||||
|
// Boucle pour organiser les termes en fonction de leurs parents
|
||||||
|
foreach ($ThematiquesTerms as $term) {
|
||||||
|
if ($term->parent == 0) {
|
||||||
|
// Si c'est un parent, on le place dans le tableau des parents
|
||||||
|
$terms_by_parent[$term->term_id] = ['term' => $term, 'children' => []];
|
||||||
|
} else {
|
||||||
|
$child_terms[$term->parent][] = $term;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Réunir les termes parents et leurs enfants
|
||||||
|
foreach ($terms_by_parent as $parent_id => &$parent_data) {
|
||||||
|
// Ajouter les enfants au parent
|
||||||
|
if (isset($child_terms[$parent_id])) {
|
||||||
|
$parent_data['children'] = $child_terms[$parent_id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $terms_by_parent;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------
|
/* -------------------------------------------
|
||||||
GET PARCOURS PREVIOUS/NEXT POSTS
|
GET PARCOURS PREVIOUS/NEXT POSTS
|
||||||
---------------------------------------------*/
|
---------------------------------------------*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user