The Menu Allocator module is a ProcessWire module that allows you to allocate menus to pages in your ProcessWire CMS installation. You can define menus and assign them to pages, making it easy to manage page navigation and menus in your site.
- Download the module's ZIP file from the GitHub repository.
- Extract the ZIP file and place the
MenuAllocator
directory into your ProcessWire site's/site/modules/
directory. - In the ProcessWire admin, go to Modules > Refresh.
- Find the "Menu Allocator" module in the modules list and click the "Install" button.
After installation, you can configure the module settings:
- Go to Modules > Configure > Menu Allocator.
- Define your menus by entering menu names, separated by spaces. For example:
topmenu mainmenu footermenu
- Save your changes.
- Edit a page in the ProcessWire admin.
- In the page editor, you'll see a "Menus" section where you can select the menus for that page.
- Choose the menus you want to allocate to the page.
- Save the page.
You can retrieve pages associated with a specific menu using the getPageArray
method provided by the module:
// Example usage to retrieve pages associated with the 'top' menu
$topMenuPages = $modules->get('MenuAllocator')->getPageArray('top');
// Example usage to retrieve pages associated with the 'footer' menu
$footerMenuPages = $modules->get('MenuAllocator')->getPageArray('footer');
// Now $topMenuPages and $footerMenuPages contain arrays of pages associated with the respective menus
// Example: Display the 'top' menu
echo '<ul>';
foreach ($topMenuPages as $page) {
echo '<li><a href="' . $page->url . '">' . $page->title . '</a></li>';
}
echo '</ul>';
// Example: Display the 'footer' menu
echo '<ul>';
foreach ($footerMenuPages as $page) {
echo '<li><a href="' . $page->url . '">' . $page->title . '</a></li>';
}
echo '</ul>';