Would it be possible to hide the checkbox "Send to all affiliates" and make the domain selection mandatory?
Right now both options are visible. I think this is strange behaviour (why is it possible to select a domain after checking "Send to all affiliates"?) which can be improved.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Domain selection is already forced.

You must select a domain even if "send to all affilaites" is checked, as this is the 'root domain' for the node and is used for editing and linking purposes.

You could have a separate permission that would allow the removal of 'send to all affilaites', but I believe the current permissions cover this, see section 3 of the README.

You can do what you want now with a simple hook_form_alter. Just set $form['domain_site'] = array('#type' => 'value', '#value' => FALSE).

I might consider looking at a patch.

nonsie’s picture

Just my 2 cents - on one of our sites we've approached it the other way around, when "send to all affiliates" is checked a specific domain (in our case default) is checked as well. All it takes is some jquery magic. You could reverse this approach if you wanted "publish to all" checked when a specific domain is checked.

nrackleff’s picture

Hi, I could use a little clarification too.

We are setting up a site with 3 domains and the users would like us to be able to hide the 'send to all affiliates' checkbox completely, but they would still like to be able to publish content to any and all domains by checking individual boxes only.

Is there a way to do this with the current configuration and permissions settings? If so, could you let me know what settings I need to select to make this happen? I have read section 3 of the readme.txt file and it is still unclear to me.

Thanks for your help,
Nancy

nrackleff’s picture

I read through the readme.txt again and I think I may have answered my own question. In the domain access config, I need to assign the users to all domains. In permissions, uncheck 'set domain access' and check 'publish to any assigned domain'. That seems to have taken care of it. Thanks, Nancy

agentrickard’s picture

Status: Active » Closed (fixed)

That would do it, yes. Or you could use hook_form_alter() in a custom module.

JuliaKM’s picture

Just wanted to add a quick jQuery example to follow up on comment #2 in case someone stumbles onto this issue later on. I wanted to uncheck the "send to all affiliates" box by default using jQuery. Keep in mind that, as the other comments have mentioned, this box will be unchecked as long as you have not selected to share the content for a particular node type under Domain Node Types (admin/build/domain/advanced). To uncheck the affiliates box, I added the a js file containing the following to my custom form_overrides module.

$(document).ready(function() {
if ($('input[name=domain_site]').is(':checked'))
{
  $('input[name=domain_site]').attr('checked', false);
}
});

Then, I used drupal_add_js within hook_form_alter to attach the js to a particular node type.

function form_overrides_form_alter(&$form, $form_state, $form_id) {
    switch ($form_id) {
    case 'webform_node_form':
           drupal_add_js(drupal_get_path('module', 'form_overrides') .'/uncheck_domain.js');
    break;
  }
}

I think that there's probably a better way to do this using Drupal behaviors. Additionally, just using hook_form_alter may be a simpler solution.

mgifford’s picture

Version: 6.x-2.0-rc8 » 7.x-2.0
Status: Closed (fixed) » Active

This really should be an admin config option in the Domain settings.

agentrickard’s picture

Version: 7.x-2.0 » 7.x-3.x-dev

New features go in 7.x.3.

Waiting for a patch.

mgifford’s picture

That's fair. I was hoping that #6 would be something close enough to roll up, but...

mgifford’s picture

I'm trying to do this now with PHP to directly alter the database. Annoying.

agentrickard’s picture

Don't alter the database. Wow.

Use hook_node_access_records_alter() if you must.

See also #275278: Document: default domains for content types which is related and might be made to include this feature.

mgifford’s picture

I am really frustrated by this module.

I raised this issue back in February to try to move it forward before the site has to launch.. Sadly, I got pulled away to other things.

Seems to be required to deliver mobile versions for sites. I just want a http://m.example.com to go to one theme and http://example.com to go to another.

Shouldn't be that hard. By default everything should be available everywhere. I want to be able to target maybe 1% of the content to either desktop specific content or mobile specific content. But really, that would be a perk & can be managed a bunch of other ways.

I can make sense of the database & troll trough it. Seems that it needs either the domain_site & possibly the domain_id for both of the domains I want to use. It is rather confusing how this is supposed to match up to the UI, but....

I suppose I could look at how to use this hook, but really not sure.. Haven't used it before:

http://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook...

I'm not sure how to pull what I need out of the default domains issue queue.. Lots of code I'm not familiar with and ultimately I don't know how the patch in #55 is supposed to be improved based on your feedback in #56.

I'm not a UX person. I don't want to deal with any more than 2 domains. Unfortunately I've got thousands of nodes already inserted into my site that are presently set up with incorrect settings for the domain access.

Maybe we need to sit down and think about simple, common use cases first. Figure out how to manage that. Then think about how it can be improved and simplified for dozens of sites.

I know it's hard to maintain modules and deal with folks like myself. I have been trying to figure out how this module works though..

I want a batch processing function that allows me to force permissions on all nodes. Batch processing should allow for that....

I have been trying to help move this forward so that it is easier for everyone to understand.. Hope this rambling helps to some degree.

agentrickard’s picture

By default, everything _is_ available everywhere. You just want to hide that setting, which you can do with a simple hook_form_alter().

There are batch update settings already provided as well.

As for understanding the database, you should read the docs: https://drupal.org/node/1096982

The difficulty, as a maintainer, is that you are asking for things that already exist or are easy to implement -- but not worthwhile enough to most users to include in the module.

agentrickard’s picture

But seriously, if you just want to hide the initial "Send to all affiliates", here's the code. It goes in a domain_custom module.

function domain_custom_form_alter(&$form, $form_state) {
  // Apply to all node editing forms only.
  if (empty($form['#node_edit_form'])) {
    return;
  }
  // Remove the element we don't want.
  if (isset($form['domain']['domain_site'])) {
    $form['domain']['domain_site']['#type'] = 'value'; // Set to a static value, hidden from the user.
    $form['domain']['domain_site']['#value'] = 1; // Set to "always show on all sites". Or use 0 (zero) for the reverse behavior.
  }
}

You might also want to wrap that second IF in a permission check, so that admin users can still use this form element.

mgifford’s picture

Thanks @agentrickard we'll dig into that & see if we can help push this forward. But with our next mobile project.

Really appreciate your time on this.

BarisW’s picture

@Mike: I've done mobile sites with their own theme in the past and never needed Domain Access for this. Mobile Tools can do the theme switching based on URL and you can simply create a DNS entry m.sitename.com and a sites.php to make sure they both use the same database/settings.

I just want a http://m.example.com to go to one theme and http://example.com to go to another.

Domain Access is only needed if you need different content on the mobile site. If not, you don't need Domain Access at all.

Cheers, BarisW

agentrickard’s picture

@BarisW is correct.

mgifford’s picture

I'll give Mobile Tools a try again. Domain is probably just be overkill for what I need.

I know a lot of work has gone into Mobile Tools in the last few months so will take a look, particularly with integration with JQM type tools.

Thanks for your help!

agentrickard’s picture

If all you need is theme switching, you can do that in a custom module with hook_custom_theme(). Piece of cake.

robidigital’s picture

@BarisW: Try playing with the node-type specific settings for Domain Access (/admin/build/domain/advanced). These can be accessed through Domain Access->Settings->Domain Module Behaviors, select "Only show on selected sites", then click on "Node-type specific settings" for more advanced options. Hope that helps!

agentrickard’s picture

Status: Active » Closed (works as designed)
pratip.ghosh’s picture

I am not sure, whether you have checked this in Drupal 7? Here there is no such thing as $form['domain']

However, i am getting this 'domain' index in _field_extra_fields_pre_render function.

What's happening, any idea?

BarisW’s picture

Status: Closed (works as designed) » Needs review
FileSize
6.74 KB

Funny to see that I now have the same issue as 4 years ago, but now I know how to fix it.
Here's a patch :)

BarisW’s picture

One space too much..

BarisW’s picture

Argh, wrong patch. Anyway.. this should nail it. It adds a checkbox in the Advanced settings interface to define if the "All affiliates" should be used.

BarisW’s picture

I've also added support for the admin interface (batch updating content).

agentrickard’s picture

Worth a look, though I can see this causing lots of confusion for people.

BarisW’s picture

Issue summary: View changes

Hi Ken,

have you had the change to look at this yet? It's been a while ;)

valderama’s picture

I have tried this patch on 7.x-3.11 - it applies nicley and also works as far as I can say.

Would be a nice addition from my perspective.

dbazuin’s picture

Hi Ken,

I am wondering is there any chance this will be committed any time soon?

eevvvv’s picture

Hi

Where I can find a module to hide "Send to all affiliates"?

gaydamaka’s picture

Hi BarisW,

After node save I am getting error: Notice: Undefined property: stdClass::$domain_site in domain_source_node_validate() line 177.

mw4ll4c3’s picture

It seems prudent to mention, that I will have to modify this patch soon-ish, to allow control at the Content Type level.

An additional variable for site-wide behavior seems redundant, since access granted by "Send to All" can be disabled by defining the DOMAIN_SITE_GRANT constant as FALSE. It would make sense to use this value, to also control display of the checkbox... so that *cough* the form follows the function constant.

However, per-Type control of the behavior has no existing analog... and the logistics of that feature on a live site (especially as time goes on) more or less requires UI-based control.

agentrickard, would those changes make the patch more viable in your eyes?

mw4ll4c3’s picture

Status: Needs review » Needs work