In a recent project I used menu position to define the position based on a specific content type. However, it happened that we needed two different positions for the same content type, based on the page that is linking to it. Our solution was to add a parameter on the query string with the name of the referral. So assuming that A and B are pages both linking to the content type page C, the final query string would be C?A or C?B.

We developed a small plugin for menu position that basically adds this filtering capabilities: you specify a list of query string keys (separated by new lines) that should be present in the URL in addition to other menu position rules. This could be extended in the future to evaluate the full query string args (including not only the key, but also the value).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

matteoagosti’s picture

matteoagosti’s picture

Status: Active » Needs review
emattias’s picture

Works great!

We needed the same thing but in reverse. So here's the same patch plus a checkbox to reverse the query string rule.

Also, I added the query string plugin to the hook_menu_position_rule_plugins() implementation in menu_position.module file. Without this the patch does nothing.. :)

weseze’s picture

Here is a patch that implements key value checking on the query strings.

There are 2 todo's/nice to haves still open:

  1. implement logic to choose between OR and AND. Currently it's OR. The reverse option makes it behave like an AND.
  2. implement logic to let user choose what happens if key is not present.
matteoagosti’s picture

Assigned: matteoagosti » Unassigned

Nice one. Any plans on integrating it into next release?

mkalkbrenner’s picture

Status: Needs review » Reviewed & tested by the community

#4 works well