@@ -268,9 +268,10 @@ public function view(string $content, bool|string|array $css = false, bool|strin
268
268
private function handleNormalPage ($ content , bool |string |array $ css , bool |string |array $ js ): mixed
269
269
{
270
270
//Load the sideboxes
271
- $ sideboxes = $ this ->loadSideboxes ();
272
- $ sideboxes_top = $ this ->loadSideboxes ('top ' );
273
- $ sideboxes_bottom = $ this ->loadSideboxes ('bottom ' );
271
+ $ sideboxes = $ this ->loadSideboxes ();
272
+ $ sideboxes_side = $ sideboxes ['side ' ] ?? [];
273
+ $ sideboxes_top = $ sideboxes ['top ' ] ?? [];
274
+ $ sideboxes_bottom = $ sideboxes ['bottom ' ] ?? [];
274
275
$ header = $ this ->getHeader ($ css , $ js );
275
276
$ modals = $ this ->getModals ();
276
277
@@ -298,7 +299,7 @@ private function handleNormalPage($content, bool|string|array$css, bool|string|a
298
299
"image_path " => $ this ->image_path ,
299
300
"isOnline " => $ this ->CI ->user ->isOnline (),
300
301
"isRTL " => $ this ->CI ->language ->getLanguage () == 'persian ' || $ this ->CI ->language ->getClientData () == 'persian ' ,
301
- "sideboxes " => $ sideboxes ,
302
+ "sideboxes " => $ sideboxes_side ,
302
303
"sideboxes_top " => $ sideboxes_top ,
303
304
"sideboxes_bottom " => $ sideboxes_bottom
304
305
];
@@ -454,16 +455,23 @@ private function voteReminder(): bool|string
454
455
/**
455
456
* Loads the sideboxes, and returns the result
456
457
*
457
- * @param string $location
458
458
* @return array
459
459
*/
460
- public function loadSideboxes (string $ location = ' side ' ): array
460
+ public function loadSideboxes (): array
461
461
{
462
- $ output = [];
462
+ $ output = [
463
+ 'side ' => [],
464
+ 'top ' => [],
465
+ 'bottom ' => [],
466
+ ];
467
+
463
468
$ module = CI ::$ APP ->router ->fetch_module ();
464
- $ sideBoxes = $ this ->CI ->cms_model ->getSideboxes ($ location , $ module );
465
469
466
- foreach ((array ) $ sideBoxes as $ sideBox ) {
470
+ $ allSideboxes = $ this ->CI ->cms_model ->getSideboxes ($ module );
471
+
472
+ foreach ((array ) $ allSideboxes as $ sideBox ) {
473
+ $ location = $ sideBox ['location ' ] ?? 'side ' ;
474
+
467
475
if ($ sideBox ['permission ' ] && !hasViewPermission ($ sideBox ['permission ' ], "--SIDEBOX-- " )) {
468
476
continue ;
469
477
}
@@ -472,7 +480,7 @@ public function loadSideboxes(string $location = 'side'): array
472
480
$ fileLocation = APPPATH . 'modules/sidebox_ ' . $ sideboxType . '/controllers/ ' . ucfirst ($ sideboxType ) . '.php ' ;
473
481
474
482
if (!file_exists ($ fileLocation )) {
475
- $ output [] = [
483
+ $ output [$ location ][ ] = [
476
484
'name ' => "Oops, something went wrong " ,
477
485
'data ' => 'The following sideBox module is missing or contains an invalid module structure: <b>sidebox_ ' . $ sideboxType . '</b> '
478
486
];
@@ -483,9 +491,9 @@ public function loadSideboxes(string $location = 'side'): array
483
491
484
492
$ object = ($ sideboxType === 'custom ' ) ? new $ sideboxType ($ sideBox ['id ' ]) : new $ sideboxType ();
485
493
486
- $ output [] = [
494
+ $ output [$ location ][ ] = [
487
495
'name ' => langColumn ($ sideBox ['displayName ' ]),
488
- 'location ' => $ sideBox [ ' location ' ] ,
496
+ 'location ' => $ location ,
489
497
'data ' => $ object ->view (),
490
498
'type ' => $ sideboxType ,
491
499
];
0 commit comments