kiamlaluno's answer did not quite work for me. Using %menu_tail produced a storm of errors that the menu_tail_load function was having problems with missing arguments:
Warning: Missing argument 2 for menu_tail_load(), called in ... /includes/menu.inc on line 579 and defined in menu_tail_load() (line 827 of ... /includes/menu.inc).
Warning: Missing argument 3 for menu_tail_load(), called in ... /includes/menu.inc on line 579 and defined in menu_tail_load() (line 827 of ... /includes/menu.inc).
What did work for me was
function allow_menu_links_menu() {
$items = array();
$items['sites/d8/files/%'] = array(
'title' => 'Folder Content',
'page callback' => 'allow_menu_links_cb', /* never called */
'access callback' => TRUE,
);
return $items;
}
Then, I could serve up files in the sites/d8/files folder (and subfolders) using menu items with paths like sites/d8/files/Documents/MyFile.pdf
The menu system will then generate a link like href="/sites/d8/files/Documents/MyFile.pdf"
If you don't use the custom menu module, the menu system will reject a path starting as above.
If you try to use a path like http:sites/d8/files/Documents/MyFile.pdf
, it will produce a link like href="http:sites/d8/files/Documents/MyFile.pdf"
, which will work when you are at the root of the site, but when you are on a content page, the browser will interpret the url relative to the content page, and it will not work.
If you use a path like http:/sites/d8/files/Documents/MyFile.pdf
, the menu system will accept it, but the menu system will produce a link like href="http:/sites/d8/files/Documents/MyFile.pdf"
, which the browser (at least Safari) will interpret as href="http://sites/d8/files/Documents/MyFile.pdf"
, and fail trying to find the server named "sites".
(On further investigation, the reason the code using menu_tail fails is that you need to add the 'load arguments', as noted here: http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_tail_load/7 . If you add 'load arguments' => array('%map', '%index'),
to the definition of $items in kiamlaluno's code, it will work. The issue of whether menu_tail_load should require the explicit load arguments is also discussed here: http://drupal.org/node/298561)
(Don't forget to enable your new module, or the menu system will not accept the new links)
http://example.com/
.