Absolute urls with domain variables
beyond67 - November 5, 2009 - 17:47
| Project: | Domain Access |
| Version: | 6.x-2.0 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Is there a way to assign the urls of domain1, domain2, etc to a variable? I would like to use it to create an absolute url.
For example:
http://[domain1url]/node/55
The main reason I want to use this is to have a link to each of the affiliates on the various affiliate domains. So affiliate 2, can have a link back to the affiliate 1. A variable is best, since if I change the url of an affiliate all I have to do is update the url on the admin/build/domain/batch/subdomain screen.

#1
Just use Domain Nav. That's what it's for.
If that doesn't work for you, check the $domain['path'] part of any $domain array, which is provided by default, and provides an absolute path to the domain's root directory.
And no, a variable is not best. An accessible property is best.
If you need to add other variables to a $domain, use hook_domainpath().
#2
Thank you for the quick response and input! As you can tell Im a relative newbie, but can appreciate the power of this module.
I checked out the Domain Nav module, but it doesnt fit my needs. The $domain array may be the answer but not exactly sure of how to use it.
Let me briefly describe what i am doing. I have 2 domains (domain 1 and domain 2); more in the future. On domain 2 I will create a Page that is a description of what Domain 1 has to offer. On this Page, I want to have an image link to Domain 1 and also a link to a podcast that is on Domain 1.
So how can i edit the image link to accomplish this; to replace the DOMAIN1 below
<a href="DOMAIN1/node/55"> <img src="/sites/default/files/imagesm.jpg"/></a><a href="DOMAIN1/feeds/podcast"> <img src="/sites/default/files//podcast.jpg"/> </a>
I can use the absolute url, but i would rather use a domain property (variable?).
#3
How are you generating this page? Through module code? Theme code? Or user input?
In code, download Devel module, turn it on, and do this:
$domains = domain_domains();dpr($domains);
That will show you what you have to work with.
#4
User input
#5
You can't really do it safely in user input. You'd be better off just hardcoding the values in there.
Otherwise, you have to use PHP code in the input.
Automated url rewrites only work on PHP functions. That is, content wrapped in l() or url().
#6
The code in #3 also applies to user input that allows PHP.
#7
Thanks!! It worked.
#8
All the data you need should be in the $domain array. If you need more, you can load it using hook_domainload().