this is a great module!
I'm looking for a way for searching the content of the site[s], like multi-search. If a node was assigned to subdomain.domain.name, i cannot search it through the root domain or other sub domains.

your input is appreciated
thanks

Comments

agentrickard’s picture

This behavior is part of how node_access works, and I haven't taken the time to explore deeply.

Actually, I'm pleased that this behavior occurs, since I was afraid it wouldn't behave that way.

Some thoughts:

- Nodes assigned to 'all affiliates' -- technically, with the 'domain_site' grant set -- should show up on all domains when searching.

- I think that hook_search() and hook_form_alter() _might_ allow you to change the default node_access behavior. You would want to force all nodes to have the 'domain_site' grant. See http://api.drupal.org/api/function/hook_search/5.

- It may also be possible to force this behavior by using hook_nodeapi() and the internal hook_domaingrants to rewrite the node_access rules on-the-fly if a user is running a search.

- That said, the answer may need to be a custom implementation of hook_search. The product would be a Domain Search module.

agentrickard’s picture

So it occurs to me that there is a simple solution to half of this problem.

- Use hook_domaingrants to write grants to all domains when users perform a search.

function domain_search_domaingrants(&$grants, $account, $op) {
  $arg = arg(0); // this is the 'search' string of the url.
  if ($arg == 'search') {
    $domains = domain_domains();
    foreach ($domains as $domain) {
      $grants['domain_site'][] = $domain['domain_id']; 
    }
    return $grants;
  }
}

This _should_ make all nodes visible on the search page.

However, if you clicked on the link, it might take you to a page that is not accessible. For example:

- Node 1 is assigned to Domain A (exampleA.com)
- Node 2 is assigned to Domain B (exampleB.com)

- You search from Domain A (exampleA.com)
- Both nodes appear as search results

- Click on Node 1 -- OK, because the link goes to exampleA/node/1
- Click on Node 2 -- Access Denied, because the link goes to exampleA/node/2, but Node 2 belongs to exampleB.com

You would need to re-theme the search output so that the URLs were complete:

- Node 1 == exampleA.com/node/1
- Node 2 == exampleB.com/node/2

This can be done, but I think custom hook_search() is the answer.

Care to take a try at it?

derjochenmeyer’s picture

i have an aproach to that problem via configuration.

Scenario
subomain1: sub1.domain.com
subomain2: sub2.domain.com
subomain3: all.domain.com

Then:
I publish my content to the subdomain it belongs to.
In addition I publish my content always to all.domain.com.

Then you can create a searchpage with a dropdown that behaves like the Domain switcher block. ("search all", "seach sub1", "search sub2"). So you dont have to make the content available on all affiliate sites.

There are two things that would make life a lot easier:
1. If there was an option to automatically assign all content to an "all" sbdomain.
2. To auto-tag all content with a corresponding taxonomy term (Aso see this featre request: http://drupal.org/node/191099).

Thanks a lot for this great module!

agentrickard’s picture

Version: 5.x-1.0beta5 » 5.x-1.0beta6

Well, request #1 is already in the module, I don't think you understood the concept of the 'root' domain correctly. The use-case is as follows:

- default domain: example.com -- all nodes are assigned to this by default (can be turned off)
- sub1 : one.example.com -- nodes are assigned here if created here
- sub2 : two.example.com

So I think your use of all.example.com is incorrect. That should be your "root" domain. For aesthetic reasons, you could have your server set to all.example.com as your root domain; that's up to you.

The documentation. From section 4.1 of README.txt:

-- New content settings
Defines the default behavior for content added to your site. By design, the
module automatically assigned all content to the currently active subdomain.
If this value is set to 'Show on all sites,' then all new content will be
assigned to all sites _in addition to_ the active subdomain.

See also:

4.4.2 Domain node types

The lower section 'Domain node types' is used to extend the 'New content
settings' described in 4.1.

Domain node types presents a list of all active node types on your site. By
checking the box, nodes for that given type will automatically be assigned to
'all affiliate sites' during node creation and editing.

By default, the 'New content settings' are set to TRUE, which sends all content to all affiliates -- defined as the root domain. For the technical side, read section 5 -- especially 5.3 and 5.4. It's the 'domain_site' grant that sends content to all affiliates.

You can also adjust this setting per _node type_, as described in 4.4.2.

If you want a different use-case, you can write a submodule to use hook_domaingrants and hook_domainrecords to add or modify permissions as you see fit.

Will address the other issue separately.

agentrickard’s picture

The issue of search links is actually very problematic.

Search is not the only module affected by this issue: MySite, Bookmarks, even perhaps Node Relativity could all be affected. The issue is that a node might be validly viewed on one domain, then added to a collection that can be viewed on another domain, but on the second domain, the node view is not valid.

Since Drupal doesn't set a URL in the $node object, there doesn't seem to be a universal way to handle this without hacking the url() function.

agentrickard’s picture

Category: support » bug
Priority: Normal » Critical

Part of the fix has been committed to HEAD. Introduces the patch to provide hook_url_alter() which solves the absolute path issue.

Needs more testing.

agentrickard’s picture

Status: Active » Fixed

This behavior is now controlled through a setting. Search can be across all affiliates or per affiliate at the admin's discretion.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.