Append parameter to URL accross all pages I am on Drupal 7. My website will have a country select form on the first page where users will pick one country from a list. All these countries speak the same language (Spanish), so they are basically under the same language pack. My idea is to create a Vocabulary with all the countries I need. Then, in order to guarantee consistency accross pages (allowing me to filter content when necessary), I want to append a parameter to the URL like this:

path/to/my/page?country=ur


I want this parameter to be added to all the links on the menu in my website. Drupal will read the parameter currently in the URL and will append that same parameter to all URLs on the menu.

My idea is to use Rules to catch the current country code and append that same parameter to all links on the menu, both on top of the page AND on the footer (yes, there are two menu bars). What would be the code to add those parameters to each menu link? Do I have to run the code twice in order to change URLs from both top and bottom menus, or is it possible to inject the querystring into a single resource that will be pulled to build both menus? For the menus, I am using Menu Block module.

If you have a better idea to tackle this, please, suggest. Thank you!
The best hook for this is hook_url_outbound_alter. This affects links generated by url(), which is used by most/all code generating urls and links in Drupal.

function mymodule_url_outbound_alter(&amp;$path, &amp;$options, $original_path) {
  // If the param of interest is present and the url being generated is internal.
  if (!empty($_GET['country']) &amp;&amp; !$options['external']) {
    $options['query']['country'] = $_GET['country'];
  }
}