Menu item for the viewed contact page (with category) is not the active one

mongolito404 - September 2, 2009 - 12:56
Project:Contact Forms
Version:6.x-1.5
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I came accross an issue when using the contact_forms and the menu_block modules.

Here is my setup, the issue and then my solution.

In my primary-links menu I have the follwing items

  • Section 1 (path = content/page/page_1)
    • Section 1 subpage (path = content/page/subpage_1)
    • Section 1 contact form (path = contact/section_1)
  • Section 2 (path = content/page/page_2)
    • Section 2 subpage (path = content/page/subpage_2)
    • Section 2 contact form (path = contact/section_2)

Then I use menu_blocks to create a block witch list the subpage and contact form of the current section in my left columns.When viewing "Section 1 subpage", this block contains links for "Section 1 subpage" and "Section 1 contact form". But it doesn't work when viewing contact forms and the block is empty.

For what I understand, menu_block uses the core menu system to find the part of the menu to display. But it seems that when viewing contact/section_1 and contact/section_2, the active menu item (== the last entry in the result of menu_get_active_trail) is 'contact' which is not in the primary-links menu. So menu_block could not find out that the current page is under "Section 1" or "Sectiob 2".

I added the following functions to forms_contact fo force a menu entry to exists for the contact_forms pages

function contact_forms_menu_alter(&$items) {
  $items['contact/%'] = $items['contact'];
}

This added items is the active item when viewing a contact page with a category. So the active menu item is correctly detected and menu_block is able to find the part of the menu to display in its block.

#1

markabur - October 2, 2009 - 18:47

this works for me, i added the function to contact_forms.module and the contact page is activated in my menu. i'm not using menu_block, but i have a similar situation where the separate contact pages are not nested under /contact -- each "department" has a separate menu and a contact form in that menu.

#2

behindthepage - October 11, 2009 - 06:02
Status:needs review» fixed

Thanks guys. I missed the first post but have added this to the module.

Regards
Geoff

#3

System Message - October 25, 2009 - 06:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.