@@ -454,6 +454,8 @@ function return_navigation_array()
454454 $ navigation ['follow_up ' ]['icon ' ] = 'homepage.png ' ;
455455 }
456456
457+ buildParentCourseCategoriesMenu ($ navigation );
458+
457459 // Administration
458460 if (api_is_platform_admin (true )) {
459461 if (api_get_setting ('show_tabs ' , 'platform_administration ' ) == 'true ' ) {
@@ -481,6 +483,8 @@ function return_navigation_array()
481483 }
482484 }
483485 } else {
486+ buildParentCourseCategoriesMenu ($ navigation );
487+
484488 // Show custom tabs that are specifically marked as public
485489 $ customTabs = getCustomTabs ();
486490 if (!empty ($ customTabs )) {
@@ -508,6 +512,56 @@ function return_navigation_array()
508512 ];
509513}
510514
515+ function buildParentCourseCategoriesMenu (array &$ navigation ) {
516+ if (!api_get_configuration_value ('display_menu_use_course_categories ' )
517+ || 'true ' !== api_get_setting ('course_catalog_published ' )
518+ ) {
519+ return ;
520+ }
521+
522+ foreach (CourseCategory::getCategoriesToDisplayInHomePage () as $ category ) {
523+ $ key = 'category_ ' .$ category ['code ' ];
524+ $ navigation [$ key ] = [
525+ 'url ' => '# ' ,
526+ 'title ' => $ category ['name ' ],
527+ 'key ' => $ key ,
528+ 'items ' => buildChildrenCourseCategoriesMenu ($ category ['code ' ]),
529+ ];
530+ }
531+ }
532+
533+ function buildChildrenCourseCategoriesMenu ($ parentCode = 0 ): array
534+ {
535+ $ baseCategoryUrl = api_get_path (WEB_CODE_PATH ).'auth/courses.php? ' ;
536+
537+ $ commonParams = [
538+ 'search_term ' => '' ,
539+ 'submit ' => '_qf__s ' ,
540+ ];
541+
542+ $ items = [];
543+
544+ foreach (CourseCategory::getChildren ($ parentCode , false ) as $ category ) {
545+ $ commonParams ['category_code ' ] = $ category ['code ' ];
546+
547+ $ categoryItem = [
548+ 'title ' => $ category ['name ' ],
549+ 'key ' => 'category_ ' .$ category ['code ' ],
550+ 'url ' => $ baseCategoryUrl .http_build_query ($ commonParams ),
551+ ];
552+
553+ $ children = buildChildrenCourseCategoriesMenu ($ category ['code ' ]);
554+
555+ if (!empty ($ children )) {
556+ $ categoryItem ['items ' ] = $ children ;
557+ }
558+
559+ $ items [] = $ categoryItem ;
560+ }
561+
562+ return $ items ;
563+ }
564+
511565/**
512566 * Return the navigation menu elements as a flat array.
513567 *
0 commit comments