I am using a webform to build a basic person node and other related nodes (contact, address) at once.

I'd like to have node tabs ("Contact Infos", "Address") when showing the person node, which are showing the related nodes using url aruments like "/node/1234/contact" or "/node/1234/address".

Do I have to use the hook_menu in a custom module or is there another way to do this?

  • 1
    You can achieve this using Views by enabling "Show in menu" and selecting "Menu tab". Note that the page URL needs to be node/%/your-path and user/%/your-path so you can fetch user/node ID from the URL. Is this what you are after? – Aram Boyajyan Apr 10 '14 at 10:44
  • Hi! Please read my own answer for my solution which is not far away from yours :-) – schulle877 Apr 10 '14 at 13:20

I used panels for this. I added a new panel, which has the node with the nid of the webform as only content item in the main content area. I set the menu entry for the panel to "Menu Tab" and set the access rule of the panel to "Show only when node is of type person". This shows the desired tab element when a person node is selected.

For the webform itself I used the hook_form_alterwith the $form_id == "webform_client_form_<nid>" having <nid> as the node ID of the webform to set the #default_value of the webform field with the data coming from the person node. The ID of the person node I get by using the arg(1) function and the loading the node data with node_load($nid).

Hope that helps others.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.