Back to overview

Dynamic Menu Extension

Developer Tutorials Published on 09.11.2025
Tutorial: Dynamic Menu Extension

Dynamically Extending the Sidebar Menu

A guide to adding application-specific menu items using menu_extension.php.

Introduction

The application is designed with a multi-app architecture, allowing you to create distinct "setups" (like "INtex Adressen") that share a common core but have their own branding, features, and menu items.

One of the key extension points is the main sidebar menu. You can dynamically inject new menu items for a specific setup without modifying the core menu.php file. This is achieved by creating a special file named menu_extension.php inside your setup's dedicated folder.

The Mechanism

The core file menu.php contains a specific line of code that looks for and includes your extension file:

<?php
// --- NEU: Dynamische Menü-Erweiterung aus dem Setup-Ordner laden ---
include_setup_file('menu_extension.php');
?>

The include_setup_file() function (defined in init.php) performs the following steps:

  1. It checks if a SETUP_FOLDER constant is defined in your config.php.
  2. If it is, the function looks for a file named menu_extension.php inside that folder (e.g., setup_adressen/menu_extension.php).
  3. If the file exists, its content is directly included into the sidebar menu's HTML structure.
Step-by-Step Guide

Step 1: Define your Setup Folder

In your config.php, make sure you have a setup defined with a SETUP_FOLDER constant. For example:

// In config.php
define('SETUP_CHOICE', 'INtex Adressen');

switch (SETUP_CHOICE) {
    case 'INtex Adressen':
        define('SETUP_NAME', 'INtex Adressen');
        define('SETUP_FOLDER', 'setup_adressen'); // This is the crucial part
        // ... other constants
        break;
}

Step 2: Create the Extension File

Create a new file inside the folder you just defined. The path must be exactly:

setup_adressen/menu_extension.php

Step 3: Add Your Menu Items

Open the new menu_extension.php file and add your menu items as HTML list items (<li>). The structure should match the existing items in menu.php.

Each menu item typically consists of:

  • A list item with the class sidebar-item.
  • A link (<a>) with the class sidebar-link.
  • An icon (<i>) from Font Awesome with the fa-fw class for fixed width.
  • A span (<span>) with the class sidebar-text for the menu label.
Important: The paths in your href attributes must be relative to the application's root directory (where index.php is located), not relative to the setup_adressen folder.
Complete Code Example

Here is a complete example for your setup_adressen/menu_extension.php file. You can copy and paste this code and adapt it to your needs.

<?php
// This file is dynamically included in menu.php.
// It allows adding application-specific menu items.
?>
<!-- A divider to visually separate the new items -->
<li class="sidebar-divider"></li>

<!-- First custom menu item -->
<li class="sidebar-item">
    <a class="sidebar-link" href="setup_adressen/wv.php">
        <i class="fa-solid fa-calendar-day fa-fw icon-example"></i>
        <span class="sidebar-text">Follow-Up</span>
    </a>
</li>

<!-- Second custom menu item -->
<li class="sidebar-item">
    <a class="sidebar-link" href="setup_adressen/tutorial.php">
        <i class="fa-solid fa-circle-question fa-fw icon-example"></i>
        <span class="sidebar-text">Assistant</span>
    </a>
</li>

After saving this file, the new menu items "Follow-Up" and "Assistant" will automatically appear in the sidebar menu whenever the "INtex Adressen" setup is active.