I have one site (same codebase, same database) that uses two different domains to display two different themes, depending on the content. (This is achieved via the Domain Access module.)
I need to be able to link from one domain to a view on another domain without manually inserting the absolute URL, but I'm not sure how (or even if it's possible).*
I can use
l() to link to nodes without any problems. For example, if I'm on first-domain.com and I want to link to second-domain.com/news-story, I would do the following:
<?php print l('News Story', 'node/2213'); ?>
I don't know exactly how it works, but it realises that the news story isn't available on the first domain and automatically creates the absolute link to the second domain.
Creating a link to a view doesn't seem to be so easy. I've made sure the view's Access restrictions is set to Domains (and that only the one domain is selected) but the
l() function doesn't seem to look this up.
For example, if I'm on first-domain.com and want to link to a list of all the news stories (which is created by a view) on second-domain.com, doing this:
<?php print l('Latest News Stories', 'news-stories'); ?>
Results in a link like this:
When I really want:
Is there any way to solve this? Even if I could look up both domains that have been set via the Domain Access module would work, but I don't know how to do that either. (I've also thought about using Path Redirect, which is better than nothing, but not quite what I'm looking for.)
* Obviously it's possible to put in an absolute URL, but this is far from ideal as the site is currently being developed locally and will eventually be moved to a staging site, and then moved again to production once ready. Remembering to change the absolute links every time would be annoying at best.