On my base domain I have views-generated lists of nodes published to secondary domains. What's the correct way to get those links to go to the published domain?
I tried domain source, but that seemed to send all links on all domains to the base domain by default. Perhaps if using source domain I have to assign all existing nodes a source domain? But that would seem to not work because a node can have only 1 source but can be published to multiple domains.
So the goal is: From base domain direct links to the originating domains, which for some nodes will be the base domain. From all other domains direct links to the current domain.
This seems related to #300454: Inter domain linking, but I can't quite figure that out.
Thanks
Comments
Comment #1
agentrickardThe correct way is to use Domain Source to assign those nodes to a source domain. All links to the node will then be sent to the 'source' domain, regardless of the domain on which those links are written.
Domain Source links are only rewritten if the current domain is not the source domain.
When using Domain Source, all existing nodes would need to be assigned to a 'source' domain if you want to force links to go to a specific domain. You can use Domain Content to perform batch operations to add a source to existing content. The source works when nodes are published to multiple domains because it is merely a flag for where to send the link.
It is not related to #300454. That is a special case involving table prefixing.
Comment #2
awolfey commentedIt seems as if I'll have to find a compromise then.
1. From the national site I want links to affiliate sites' nodes to take the visitor to the originating site. Links to national nodes should keep the visitor on the national site.
2. On the affiliate sites I want the links to national nodes to keep the visitor on the current affiliate site.
3. On any one affiliate links to nodes of another affiliate should keep the visitor on the current affiliate site.
Sounds like domain source will work for 1 but won't allow 2 and 3.
Any thoughts?
Thanks for your help.
Comment #3
agentrickardFrom reading the bullet list of requests, it sounds like you don't need Domain Source at all. Just enable the default SEO Optimization. What that will do is detect whether or not linking to the current site will allow a node to be viewed. If not, it will write a link to the proper site.
In number form, these are easy to address.
1. From the national site I want links to affiliate sites' nodes to take the visitor to the originating site. Links to national nodes should keep the visitor on the national site.
This is what Domain Source is for. If the originating site is an affiliate, set a Domain Source value. If it is a national node, set the source to the national site.
2. On the affiliate sites I want the links to national nodes to keep the visitor on the current affiliate site.
Set the 'Default source domain' option to 'Do not change domain'.
3. On any one affiliate links to nodes of another affiliate should keep the visitor on the current affiliate site.
That makes no sense to me. It would only work if all content is viewable across all affiliates. And it would, as you say, contradict request #1.
The problem is that you have business rules that contradict the module design.
Your other option is to use your own copy of custom_url_rewrite_outbound. Instead of using the version provided, copy that function to a new file or to the bottom of settings.php -- be sure to remove the current include to my version of the file. THen edit custom_url_rewrite_outbound() to match your logic.
Comment #4
awolfey commentedI'll try to clarify.
We have a national site and several local affiliates.
Any time you click a link on an affiliate, no matter what the node's originating domain (affiliate or national), you view the linked node on the current domain being viewed. Example and reasoning: New York and Boston display a regional story that is of no interest to LA or Chicago. If you're on NY, we don't want you to go to the Boston domain to view it. This works now without domain source or SEO
On the national domain, when you click a link from the views generated lists of domain nodes, you should go to the originating domain. This works with domain source, but then the first part won't work.
So for number 3 above, I just mean that links on an affiliate should always keep you on the affiliate domain currently being viewed.
Any muddier?
Comment #5
agentrickardI see. You only need to rewrite paths on the primary domain.
You would need to implement your own version of custom_url_rewrite_outbound() that only rewrites the URL if $_domain['domain_id'] == 0.
That should work. Try using Domain Source, but inserting the following at line 31 of settings_custom_url.inc:
If you do not use Domain Source, this will still work, but you will have the links rewritten to the first match (based on domain creation order) and lose some control.
You should make you own copy of the settings_custom_url.inc file and put it in a different directory so it does not get overwritten on module updates.
In theory, we could provide a setting that allows this sort if control, but we have lots of settings already.
With a setting, the code looks like:
Here I have set the default value to 1, since there is no interface for changing the value.
This seems like an edge case to me. To handle it 'properly' you would need settings for Domain Source (probably) that indicate whether links should be rewritten on each domain.
We could also put in a hook to set the $skip value. That would let you write a custom module extending the behavior. I like that idea.
Comment #6
awolfey commentedOK, this works well. Except, and I should have realized this earlier, anon and authenticated users won't be able to see the links because the nodes are not viewable on the primary domain--they are only assigned to the local affiliate domain.
I could have editors assign all local nodes to the primary (national) domain as well, and then filter them out on all the other views on the primary domain's pages. Is there another option aside from giving administer nodes permission to anon users?
Comment #7
agentrickardSend the nodes to 'all affiliates' or assign them to each domain where they should be visible.
Comment #8
agentrickardYou also have the option, for page views, of telling Domain Access to ignore its access controls on certain paths.
Enter the path in the 'Special Page Requests' settings box at Admin > Build > Domains.
Doing so will make DA ignore it's own access rules. This would work well if you had a different view page for the main site -- which you can do using Domain Conf.
Comment #9
awolfey commentedI seems to be an awkward solution but I think I'm going to go with this:
1. Use a custom settings_custom_url.inc per comment #5 and SEO (Rewrite all URLs, Default source domain: Do no change domain) to only rewrite links on primary domain.
2. Use domain source so links on primary domain rewrite to specific secondary domain instead of domain by creation order.
3. Adjust other views on the primary domain so that secondary domain nodes are filtered out. I think I'll have to add a views filter for domain source to make this part work. I couldn't filter out the affiliate nodes from the primary domain nodes in the views blocks for primary nodes only. I tried various combinations of the domain views filter and also tried changing the handler to eqneq instead of or.
Comment #10
agentrickardClose the issue when you get it working.
Comment #11
awolfey commentedI copied Domain Views to a new module and modified it to replace the domain filter with a filter for domain source. If you think it might be useful to others I can work with it further, although it will be my first contribution.
Otherwise, issue is closed.
Thanks again for your generous help and time.
Comment #12
agentrickardWith the Views 2 API, we can create a Views filter for Domain Source.