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

fionamorrison23 created an issue. See original summary.

richardgaunt’s picture

Josh 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

richardgaunt’s picture

richardgaunt’s picture

@alan.cole Can you please review this and let me know if it solves your problem?

fionamorrison23’s picture

fionamorrison23’s picture

joshua1234511’s picture

Assigned: joshua1234511 » richardgaunt
Status: Active » Needs review

https://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

  1. Navigate to Structure → Menus → Add Menu.
  2. Enter a Title (e.g., "CivicTheme Sidebar Navigation").
  3. Add Menu Links as needed.
  4. Save the menu.

Step 2: Place the Menu in a Block

  1. Go to Structure → Block layout.
  2. Click Place Block in the desired region.
  3. Search for the menu you created and select it.
  4. Under HTML and Style Options, set the Theme Hook Suggestion to one of the following:
    civictheme_primary_navigation
    civictheme_secondary_navigation
    civictheme_footer
  5. Save the block placement.
fionamorrison23’s picture

Version: 1.8.1 » 1.x-dev
fionamorrison23’s picture

fionamorrison23’s picture

joshua1234511’s picture

Issue summary: View changes

  • af988e04 committed on 1.x
    Issue #3471956 by joshua1234511, richardgaunt, fionamorrison23: Enhanced...
fionamorrison23’s picture

Assigned: richardgaunt » Unassigned
Status: Needs review » Reviewed & tested by the community
fionamorrison23’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

fionamorrison23’s picture

Version: 1.x-dev » 1.12.0

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.