Problem/Motivation
At the moment we hardcode menu names to the theming layer, we should define primary, secondary, footer menus in theme settings and theme these blocks accordingly.
- see: civictheme_preprocess_block__menu_block__civictheme_primary_navigation for hardcoding theme preprocess
- and menu.inc see: _civictheme_preprocess_block__navigation and _civictheme_preprocess_block__civictheme_footer_menu
Documentation
Step 1: Create a New Menu in Drupal
Navigate to Menus:
- Go to Structure → Menus.
Add a Menu:
- Click Add menu.
- Enter a Title (e.g., “CivicTheme Sidebar Navigation”).
- Optionally, add a Description.
- Click Save.
Add Menu Links:
- After saving, click Add link to add menu items as needed.
- Fill in the Menu link title and Link (URL or path).
- Click Save after each link.
Step 2: Place the Menu in a Block
Go to Block Layout:
- Navigate to Structure → Block layout.
Place the Menu Block:
- Click Place block in the region where you want the menu to appear (e.g., Sidebar, Header, Footer).
- Search for the menu you created (e.g., “CivicTheme Sidebar Navigation”) and click Place block.
Configure the Block:
- Set the Block title (optional).
- Under HTML and Style Options (or similar, depending on your site’s configuration), look for Theme Hook Suggestion.
- Enter one of the following, depending on the menu’s purpose:
-- civictheme_primary_navigation (for main navigation)
-- civictheme_secondary_navigation (for header secondary nav)
-- civictheme_footer (for footer nav)
-- civictheme_sidebar_navigation (for sidebar nav — use this for your new sidebar menu)
- Adjust any other settings as needed (visibility, region, etc.).
- Click Save block.
Comments
Comment #2
richardgaunt commentedJosh is working on a fix:
1. Move the menu theming code into a helper _civictheme_preprocess_primary_navigation_menu and _civictheme_preprocess_footer_menu:
2. Add theme settings to define the primary navigations and the footer navigation menus
3. Update the menu name check to check for these theme settings if ($menu_name === 'THEME_SETTING')
4. Add update hook to add new theme setting or at least at a default value for expected values in this code above
Comment #3
richardgaunt commentedComment #4
richardgaunt commented@alan.cole Can you please review this and let me know if it solves your problem?
Comment #5
fionamorrison23 commentedComment #8
fionamorrison23 commentedComment #9
joshua1234511https://github.com/civictheme/monorepo-drupal/pull/1350
Modified the preprocess to set theme based on theme hook set in configuration.
Steps to Create and Style a New Menu in CivicTheme
Step 1: Create a New Menu in Drupal
Step 2: Place the Menu in a Block
civictheme_primary_navigationcivictheme_secondary_navigationcivictheme_footerComment #10
fionamorrison23 commentedComment #11
fionamorrison23 commentedComment #12
fionamorrison23 commentedComment #13
joshua1234511Comment #15
fionamorrison23 commentedComment #16
fionamorrison23 commentedComment #18
fionamorrison23 commented