Please help me think about this problem and find a cleaner solution than I have found by myself.
A menu item is supposed to display a page at a fixed location on another site. Sounds simple, doesn't it? It would be, except that the client wants the page to be displayed in a new window or tab.
The only way I know of doing that is to link to a fixed page on my own site which opens a window and redirects it:
<head>
<meta HTTP-EQUIV="Refresh" content="0;url=http://www.somewhereelse.com/somepage.html" target="_blank">
</head>
I don't think I can do that by making a menu item display a node. It must display a static "redirect page" stored somewhere in my site. At present the redirect page is in a subdirectory of files (the Drupal file system directory).
Now add a multisite configuration to the mix. There will be one site for production and another for testing. Later there may be additional sites for users in different countries. All of the sites have the same menu item, but each one might need to display a different off-site page, so each one needs to load a different redirect page.
The clean way to do that would be to put the redirect page somewhere in sites/example.com/files. Then each site can have its own redirect page.
But how can I make a menu item refer to a file whose location is defined relative to the sites directory?
One way would be to use absolute URL and change it on each site. That's ugly; it "breaks" Drupal's multisite design and makes me change something (something obscure that I'm likely to forget) each time I create a new site.
I haven't tried this yet, but I gather I could build the menu item dynamically by defining a hook_menu function. Then I could write code that made the menu items path be anything I wanted. The documentation is vague about when this function gets called, but I hope it would be called when I executed update.php in the course of creating a new site.
But this is ugly too. Apart from requiring a great deal of code to do something that started out being very simple, it violates the principle of locality: that related things should be kept together (in this case, that all of the entries in a particular menu should be defined in the same way and the same place).
And it might not even work for me. The documentation says that hook_menu will only make entries in the navigation block or the menu administration page, which is a deal-killer if true, because I need to make an entry in the primary links. It's also arguably an abuse of the hook, which is designed to be used (in accord with the principle of locality) in a module to define menu items for that module.
What other approaches might be possible?
Comments
You can probably do something like this
This code here looks for a path of <none> and then replaces the link destination with a javascript void - basically it makes a link go nowhere.
In template.php
My theme is pushbutton - replace with your theme name.
You should be able to make that work by adding target "_blank" and the proper URL to the return.
Thank you --
Thank you -- that hook looks like it will do exactly what I want. I confess that I don't understand the part about JavaScript, but I see how the hook could be used to replace a placeholder with the appropriate domain name.