Header menu by command line
Two commands add a page to the header menu: exp:ini add writes the node ID into menu.ini, exp:cache clear makes
the site show it. Run them in the installation's root directory. As root, add --allow-root-user to every command (the
output below was made that way; the option is left out of the prompts for readability).
Contents
- See where the list is set
- Preview the change
- Write it
- Clear the caches
- Check the result
- The same for every siteaccess
1. See where the list is set
exp:ini where lists every file that sets a setting, in the order they are read, and the value in effect:
$ ./console exp:ini where menu.ini/SiteInfo/MainMenuID site
menu.ini/SiteInfo/MainMenuID (load order of siteaccess site)
1. extension/sevenx_themes_media/settings/siteaccess/site/menu.ini.append.php scope extension:sevenx_themes_media:siteaccess:site
MainMenuID[]=79
MainMenuID[]=117
MainMenuID[]=131
MainMenuID[]=150
MainMenuID[]=151
2. settings/siteaccess/site/menu.ini.append.php scope siteaccess:site
MainMenuID[]=92
MainMenuID[]=130
MainMenuID[]=144
MainMenuID[]=163
MainMenuID[]=164
MainMenuID[]=26210
MainMenuID[]=192
In effect:
MainMenuID[]=92
...The second file (scope siteaccess:site) is the one in effect, so that is the scope to write. (This listing already
has 192, added in the administration on the other page.)
2. Preview the change
--dry-run shows the change as a diff and writes nothing. The example adds Contact (node 185):
$ ./console exp:ini add menu.ini/SiteInfo/MainMenuID[] 185 siteaccess:site --dry-run
--- a/settings/siteaccess/site/menu.ini.append.php
+++ b/settings/siteaccess/site/menu.ini.append.php
@@ -10,6 +10,7 @@
MainMenuID[]=164
MainMenuID[]=26210
MainMenuID[]=192
+MainMenuID[]=185
NexusMainMenuID[]
NexusMainMenuID[]=167
NexusMainMenuID[]=168
Dry run: add to menu.ini/SiteInfo/MainMenuID[] in siteaccess:site, nothing writtenadd appends: the new item becomes the last one. For another position, see
Reorder or remove header menu items.
3. Write it
$ ./console exp:ini add menu.ini/SiteInfo/MainMenuID[] 185 siteaccess:site
Add to menu.ini/SiteInfo/MainMenuID[] in siteaccess:site: settings/siteaccess/site/menu.ini.append.php
Backup: var/backup/ini/20261019-031440/settings/siteaccess/site/menu.ini.append.php
INI cache: cleared tag ini: 5 caches
Hint: PHP-FPM reads the change on its next request (ini cache cleared); Velocity workers keep the settings of their warm-up: exp:velocity restart to apply it there.
DoneThe file is written line by line (comments and order stay), atomically, after a backup copy under var/backup/ini/.
The INI cache is cleared. As the hint says, a site served by Exponential Velocity applies the change after
./console exp:velocity restart.
4. Clear the caches
The header's menu template is compiled with the list of IDs in it, so clear the template and content caches:
$ ./console exp:cache clear --tag=template,content
exphttpcache on content,template new HTTP cache generation: every stored page becomes stale
template on template directory removed
template-block on template,content expiry timestamp global-template-block-cache set, directory moved aside
template-override on template directory removed, in-memory override list emptied
...
content on content expiry timestamp content-view-cache set, directory moved aside
...
PASS cleared tag template, content: 17 caches5. Check the result
The menu items carry the attribute id="menu-item-main_menu-location-id-<id>", so a quick check is:
$ curl -s https://www.example.com/ | grep -o 'menu-item-main_menu-location-id-[0-9]*' | tail -3
menu-item-main_menu-location-id-26210
menu-item-main_menu-location-id-192
menu-item-main_menu-location-id-185(On this site the first five items show the IDs from NexusMainMenuID[] in that attribute instead, see
How the header is built.)
6. The same for every siteaccess
Each site siteaccess can have its own list. To find all of them: ./console exp:ini scopes lists the scopes the
installation has, and exp:ini where menu.ini/SiteInfo/MainMenuID <siteaccess> shows the list in effect for one of
them. Write each one with its own scope, siteaccess:<name>. The scope global (settings/override/menu.ini.append.php)
is read after every siteaccess file, so a value added there is added to the list of every siteaccess; keep menu lists
in the siteaccess files, where each site has its own.
Related pages
- Add a header menu item
- exp:ini for site builders
- Caches after a change
- Measured steps and times
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.