Multiple domain names on a single node same culture
Hello all,
I have a multilingual website. Each language is a root node. I'm using relations to link pages with the same content but different language.
Each language root note has two domains with the same culture. One for the domain and one is localhost one (for development)
eg.
Home (French) ----- fr.xyz.ca (fr-ca) and fr.xyz.localhost (fr-ca)
Home (English) ----- en.xyz.ca (en-ca) and en.xyz.localhost (fr-ca)
when I look up the relation on the production server from French to the corresponding English node - the url always defaults to .localhost regardless of what order the localhost appears in the Culture.Hostname on the node.
Any ideas how I can retrieve the list of domains under the corresponding node?
I've tried AbsoluteUrl, Url of the IPublishedContent but all return localhost
I had this recently and had to do some string manipulation this was for 4..11 site, you may need to tweak to fit your situation.
/// <summary>
/// a node can have more than one domain doing full url with domain
/// via umbraco api will give you the first one it finds which may not be correct
/// one, so get all the domains and compare with current request url and match
/// </summary>
/// <param name="url"></param>
/// <param name="node"></param>
/// <returns></returns>
public static string GetFullUrlWhenMultiDomain(string url, IPublishedContent node)
{
string host = HttpContext.Current.Request.Url.Host;
string protocol = HttpContext.Current.Request.Url.Scheme;
if (host[2] == '.')
{
host = host.Substring(2);
}
var domains = Domain.GetDomainsById(node.Id);
foreach (var domain in domains)
{
if (domain.Name.Contains(host))
{
return protocol + "://" + domain.Name;
}
}
return url;
}
Thanks very much! For some reason when I searched I didn't see this thread.
Your solution gets me closer than I have been before. Some of my domains I'm working with don't end in xyz.com some are xyz.fr, xyz.de etc. but thanks for your help.
Multiple domain names on a single node same culture
Hello all,
I have a multilingual website. Each language is a root node. I'm using relations to link pages with the same content but different language.
Each language root note has two domains with the same culture. One for the domain and one is localhost one (for development)
eg.
when I look up the relation on the production server from French to the corresponding English node - the url always defaults to .localhost regardless of what order the localhost appears in the Culture.Hostname on the node.
Any ideas how I can retrieve the list of domains under the corresponding node?
I've tried AbsoluteUrl, Url of the IPublishedContent but all return localhost
Cheers John
John,
I had this recently and had to do some string manipulation this was for 4..11 site, you may need to tweak to fit your situation.
Regards
Ismail
Thanks Ismail for this. Do you know if there is an v7 equivalent to
Domain.GetDomainsById(node.Id);
as I gather it's deprecated
https://our.umbraco.org/forum/developers/api-questions/71635-applicationcontext-services-domaingetdomains-equivalant
Thanks very much! For some reason when I searched I didn't see this thread.
Your solution gets me closer than I have been before. Some of my domains I'm working with don't end in xyz.com some are xyz.fr, xyz.de etc. but thanks for your help.
I'm closer to a solution.
is working on a reply...