{"record":{"id":"9f7d1f719aabb219","repo":"octobercms/october","slug":"unable-to-add-navigation-items-before-they-are-loa","errorCode":null,"errorMessage":"Unable to add navigation items before they are loaded.","messagePattern":"Unable to add navigation items before they are loaded\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/backend/classes/NavigationManager.php","lineNumber":214,"sourceCode":"     * @param array  $definitions\n     */\n    public function addMainMenuItems($owner, array $definitions)\n    {\n        foreach ($definitions as $code => $definition) {\n            $this->addMainMenuItem($owner, $code, $definition);\n        }\n    }\n\n    /**\n     * addMainMenuItem dynamically adds a single main menu item.\n     * @param string $owner\n     * @param string $code\n     * @param array  $definition\n     */\n    public function addMainMenuItem($owner, $code, array $definition)\n    {\n        if ($this->items === null) {\n            throw new SystemException('Unable to add navigation items before they are loaded.');\n        }\n\n        $itemKey = $this->makeItemKey($owner, $code);\n\n        if (isset($this->items[$itemKey])) {\n            $definition = array_merge(\n                $this->items[$itemKey]->toArray(),\n                $definition\n            );\n        }\n\n        $item = array_merge($definition, [\n            'code'  => $code,\n            'owner' => $owner\n        ]);\n\n        $sideMenu = array_pull($item, 'sideMenu');\n","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/backend/classes/NavigationManager.php#L196-L232","documentation":"Thrown by NavigationManager::addMainMenuItem when navigation items have not yet been loaded from plugin registration (the internal $items collection is still null). It is an order-of-operations guard: you cannot dynamically add menu items before the main menu set has been registered/loaded.","triggerScenarios":"Thrown at modules/backend/classes/NavigationManager.php:214 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the items via the plugin's registerNavigation() so they load with the system","Defer dynamic additions until after navigation is loaded (e.g. listen for the backend.menuExtendItems / system.ready event)","Call a loading method (e.g. getMainMenuItem / ensure loaded) before adding items dynamically"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","contentChangedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}