Set active domain as source
| Project: | Domain Access |
| Version: | 6.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Hi,
I've tried quite some settings but just can't find the solution. My setup and goal is as followed;
- primary site
- secondary sites (subdomains)
All share the same view with a filter; Domain Access: Available on current domain => True
Now this works like a charm. Yet the links in this view are linked to the source domain.
So if an admin was to post a node from the primary site and send to all affiliates the node title will show up in the view on subdomain.example.com but the link will send a user to the node www.example.com. Is it possible to have links to nodes that are published to all affiliates (no matter what the source is) made relative to the (sub)domain on which the view is shown.
This way the node would be shown on subdomain.example.com as it was it's own content. I know this may cause duplicate content problems but we'll wory about that later ;)
Thanx in advance!
Bartezz

#1
Please read the documentation, particularly section 4.3.3 of README.txt.
#2
Ah I found out this is caused by Domain Source module, duh ;)
Well a solution would be to disable this module. Yet I prefer to have a setting under node/x/edit => Source domain.
Now I only have the option to set the default or any of the affiliate domains as the source domain.
It would be nice to have an option 'current domain'. Or maybe somehow set this per content type, or both :)
That way I create a node of the news content-type and send them to all affiliates as being their own news (eg. one node being available under www.example.com/node/99 AND sub1.example.com/node/99 AND sub2.example.com/node/99). And create a node of the page content-type and send them to all affiliates but linking them back to the source (eg. one node used in views on all affiliate sites but always linked to www.example.com/node/100).
It would become an option per node or content-type instead of all or nothing which is the situation now by en/disabling Domain Source module.
Cheers,
Bartezz
#3
Here's a screenshot of my settings.
#4
If you turn off Domain Source, then you can use the 'default source' setting for nodes sent to 'all affiliates.' Other nodes will link to the first matching domain.
The advanced logic you want is very tricky to implement, and not on the table for the stable release. I would welcome a patch.
#5
Well, I can see what i can do ;)
#6
Well, I'll see what I can do :)
#7
Hi Agentrickard,
I've made some changes to the code and was hoping you could take a look at it.
I think I need to do some more editing to implement user permissions but for user 1 as administrator it's working I believe.
I've added an option under node/edit => 'source domain' called 'Active domain as source', this option has a domain_id of -1.
In the domain souce nodeapi I changed the load function to check if the $source == -1 and if so to set the node->domain_source to the $domain['domain_id']
As I still haven't found out how to create proper patches here's my version of the .module file, sorry for this. (Edits are commented with //edit Bartezz)
Let me know what you think!
Thanx & Cheers
#8
Oops, I zipped the wrong file. This is the working one;
#9
Any chance of a proper patch?
http://drupal.org/patch/create
#10
Hi,
I've tried for about an hour to do so. Working with TortoiseSVN and WinMerge but somehow all the patches I create with those just comment out the whole code and then plus it back in there if you get what I'm saying.
#11
Use Unix-formatted line breaks in your text editor.
#12
Sorry... will look into that on monday.
Have you been able to take a look?
Cheers
#13
No, I have not.
#14
Hi AgentRickard,
Well I think I finally found the way to create a proper patch. Hope this one works better for you.
Cheers
#15
That looks like it just might work. Any independent testers out there?
My only concern is the -1, which we have to use all over the code to overcome the limitations of checkboxes in FormAPI. I'm used to converting -1 to 0 all the time, so maybe we make this -5 or some other obvious marker so we don't get confused.
See the nasty logic in domain_source_nodeapi('validate'):
<?php// Cast the key from zero to -1 to match the data coming from the input.
($node->domain_source == 0) ? $key = -1 : $key = $node->domain_source;
if ($node->domain_site && $key == -1) {
?>
#16
Yeah sure, fine by me. It has to be an int(11) though database-whise.
I was looking at source domain per content-type solutions in the forum (#275278)
to see if I could implement this in there as well but there's nothing mature enough to work with is there?
Is this something you are working at and I could maybe help you implement this 'active domain as source domain' function with?
Cheers
#17
I am not working on [#275287] right now. Other people are, and I think morbus is able to release something.
#18
Alright then!
How about it Morbus? Do you think this will make it in?
Cheers
#19
Is there a way I can contact morbus about this? He doesn't seem to be reading this issue.
What's his user ID?
Cheers
#20
That's because the discussion of content types per domain is OFF-TOPIC here. Go read the other thread listed in #16.
#21
Hi Agentrickard,
What does my patch have to do with 'content types per domain'?
This patch just adds an option to change the source domain for any node!
Cheers
#22
Read #17, #18 and #19 again. You brought it up. Morbus has nothing to do with this patch. He was (I believe) working on per-content type settings.
Contacting Morbus to review this issue makes no sense.
#23
Sorry about any miscommunication!
I thought [#275287] was a bout per-content type settings, for instance creating a setting to have nodes of the content-type 'page' always published to subdomain pages.mydomain.com and nodes of the content-type 'book' always published to books.mydomain.com.
My patch is not related to this feature/functionality. It merely allows an admin to set the source domain for a node (upon creation and not as a per content type setting) to 'Active domain as source'. The idea behind it is for subdomains not to 'lose' visitors to the node publisher domain.
For instance, on my setup I have a view for news headers which are shown in a block on the primary domain and on all subdomains.
(The admin for the primary domain publishes to all affiliates, the maintainers of subdomains only publish to their subdomain.)
Currently the source can only be set to primary domain, subdomain a, subdomain b, etc by the admin (who has all permissions).
The best choice currently would be primairy domain in my case.
But by doing that, the clickable node titles shown in the view list on a subdomain will direct a visitor to the node's source domain to display the full node and thus the subdomain will lose the visitor to the primary domain. By setting the node's source domain to 'Active domain as source' with my patch the node will be shown on the subdomain itself.
I hope this will clear things up :) Not trying to be a pain in the... but tell me if I still am and still should contact Morbus about this!
Cheers
PS. I mentioned 'per content type settings' in #16 just so that if you think this patch has potential I could try to implement similar functionality in the 'per-content type settings' but the patch works without implementation into that feature as well, but just on a per node basis!
#24
#25
Better title
#26
The patch was badly malformed. Please see http://drupal.org/patch/create for guidelines.
It also overlooked a lot of the edge case code that is in Domain Source, when dealing with non-administrative users, and it lacked proper form validation. (You cannot assign something to 'use active domain' if it is not sent to 'all affiliates'.)
However, I also uncovered some buggy code in Domain Source, including a permission typo. This patch should correct all that and add the new functionality.
#27
Hey agentrickard,
Sorry about a bad patch! But thank you a million for creating a proper one!
Will test and post back!
Cheers
#28
Hi again,
Finally had a chance to proper test it and although it seems to work nicely I have one problem with it though;
Only content viewable by all affiliates may be assigned to the active domain.That means that if the admin desires to publish news, which preferably is shown on the subdomains as it were their news, you can now set the source to 'Use active domain'. But the news has to be 'send to all affiliates' which isn't always preferred. Let's say your affiliates are shops, some small shops, some larger. You want to send out the news that larger shops now carry product X you now either have to send this news to all affiliates (even when it's useless news for smaller shops) or you have to set the source domain to be a certain domain thereby linking off of the affiliate domain.
Hope you understand my hectical description.... getting tired had to rebuild the whole site (see other thread ;) )
Cheers
#29
Hi again,
Finally had a chance to proper test it and although it seems to work nicely I have one problem with it though;
Only content viewable by all affiliates may be assigned to the active domain.That means that if the admin desires to publish news, which preferably is shown on the subdomains as it were their news, you can now set the source to 'Use active domain'. But the news has to be 'send to all affiliates' which isn't always preferred. Let's say your affiliates are shops, some small shops, some larger. You want to send out the news that larger shops now carry product X you now either have to send this news to all affiliates (even when it's useless news for smaller shops) or you have to set the source domain to be a certain domain thereby linking off of the affiliate domain.
Hope you understand my hectical description.... getting tired had to rebuild the whole site (see other thread ;) )
Cheers
#30
IF you don't put this restriction in, you have to do some very nasty change management logic. You want to try to expand on the patch above?
#31
Hi,
I took this code out:
+ // If 'Use active domain' is selected, then the node must be viewable on all affiliates.+ if ($node->domain_source == DOMAIN_SOURCE_USE_ACTIVE && !$node->domain_site) {
+ form_set_error('domain_source', t('Only content viewable by all affiliates may be assigned to the active domain.'));
+ }
Works like a charm now. Will provide a patch on monday as I can't get to repository from here.
What management logic would become so nasty then? I was thinking of the reason you put it in there but couldn't think of one?
Cheers
#32
Updated patch for HEAD. Still requires the all affiliates option. Trying to recall why I had that restriction.
#33
The answer has to do with being forced to rewrite the logic in custom_url_rewrite_outbound() to account for this change.
#34
This is what I mean. Much larger patch that introduces new API functions, because we have to alter how this data is loaded.
If the node is not visible on the current domain, then that domain cannot be used as the source.
This patch is 3x more complex than the original.
#35
Hi,
Thanx, will try tomorrow. Haven't had time to provide you with a patch yesterday but I guess I don't need to now :)
Will this patch allow me to set active domain as source without having to send it to all affiliates then?
Thanx a million for this feature!!!
Cheers
#36
Yes. It does. That's what causes all the extra logic, since we cannot dynamically assign content to an unavailable source.
#37
Great!!!! You're a lifesafer, thanx for this. Will test this first thing in the morning.
Now off to bed... my 4th night in a row with <5hrs sleep finally got to me...
Ain't 18 anymore, that's for sure!
Cheers
#38
Committed patch and tested the submission of a node with 'active domain as source' and 'send to all affiliates', no more warnings and seems to be working fine.
Anything else you want me to test?
Cheers
#39
Does it break anything else? Do links go where they should?
#40
Crap, I wasn't looking good enough I guess.
When I send a node to 'send to all affiliates' without checking the individual 'publish to' domains it won't show up in a node list view anymore. It was showing up here before...
When I do check the individual 'publish to' domains they do show up in the node list view but the links point to the primary domain instead of the active domain.
The 'send to all affiliates' setting DOES work for sending nodes to menus but the links point to the primary domain instead of the active domain.
I ran update.php and resaved the nodes after doing so, so that's not causing it.... :(
Cheers
#41
Rolled back to rc9 with changes made in #31...
Found out that the View wasn't working as expected there either.... have a filter [Domain Access: Available on current domain True ] which only works if I check individual nodes not if i check 'send to all affiliates'.
Cheers
#42
Found the Views problem in #40... I updated to HEAD but forgot to apply your patch: http://drupal.org/node/561282#comment-2114040
When rolling back to rc9 I also forgot about this patch.
My appologies for the confusion, working with various versions and keeping up with patches sometimes becomes too much!
Will update to HEAD again and apply the patch mentioned above and your patch in #34 and post my findings :)
Cheers
#43
Alright... updated to HEAD again and applied patches posted here;
- http://drupal.org/node/561282#comment-2114040 (can you commit this to HEAD?)
- http://drupal.org/node/540684#comment-2172770
So far it's all looking good :) Am a happy man!
The problems stated in #40 are all gone!
Cheers
#44
Committed to HEAD.
#45
Cheers!
#46
Automatically closed -- issue fixed for 2 weeks with no activity.