octobercms/october · error · SystemException
Unable to add navigation items before they are loaded.
Error message
Unable to add navigation items before they are loaded.
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/backend/classes/NavigationManager.php:214 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/9f7d1f719aabb219.
Report an issue: GitHub.
Appendix: source
Thrown at modules/backend/classes/NavigationManager.php:214
* @param array $definitions
*/
public function addMainMenuItems($owner, array $definitions)
{
foreach ($definitions as $code => $definition) {
$this->addMainMenuItem($owner, $code, $definition);
}
}
/**
* addMainMenuItem dynamically adds a single main menu item.
* @param string $owner
* @param string $code
* @param array $definition
*/
public function addMainMenuItem($owner, $code, array $definition)
{
if ($this->items === null) {
throw new SystemException('Unable to add navigation items before they are loaded.');
}
$itemKey = $this->makeItemKey($owner, $code);
if (isset($this->items[$itemKey])) {
$definition = array_merge(
$this->items[$itemKey]->toArray(),
$definition
);
}
$item = array_merge($definition, [
'code' => $code,
'owner' => $owner
]);
$sideMenu = array_pull($item, 'sideMenu');
View on GitHub (pinned to b608633a7e)