@@ -454,6 +454,8 @@ function return_navigation_array()
454
454
$ navigation ['follow_up ' ]['icon ' ] = 'homepage.png ' ;
455
455
}
456
456
457
+ buildParentCourseCategoriesMenu ($ navigation );
458
+
457
459
// Administration
458
460
if (api_is_platform_admin (true )) {
459
461
if (api_get_setting ('show_tabs ' , 'platform_administration ' ) == 'true ' ) {
@@ -481,6 +483,8 @@ function return_navigation_array()
481
483
}
482
484
}
483
485
} else {
486
+ buildParentCourseCategoriesMenu ($ navigation );
487
+
484
488
// Show custom tabs that are specifically marked as public
485
489
$ customTabs = getCustomTabs ();
486
490
if (!empty ($ customTabs )) {
@@ -508,6 +512,56 @@ function return_navigation_array()
508
512
];
509
513
}
510
514
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
+
511
565
/**
512
566
* Return the navigation menu elements as a flat array.
513
567
*
0 commit comments