I have 17,000 nodes and want to batch change all the content to be only assigned to one domain. Is there a quick way to do this?

Comments

blasto333’s picture

I tried:

DELETE FROM domain_access WHERE realm = 'site_all' and then rebuilding the nodeaccess cache, but that shows the correct number of 0 nodes assigned to all affiliates, but when I click it, I see all the content.

scuba_fly’s picture

Status: Active » Postponed

You can do this by using the module "Domain Content"
Not sure for version 7.x-2.16 but in version 7.x-3.x-dev this module is included.

if you go to admin/content you now have a new option "SHOWAFFILIATE PUBLISHING OPTIONS" to batch update all or any checked content.

for still seeing all content make sure you have the checkbox checked for administrators so content of other domains will not show up admins. or log out and see if it's still there. Not sure where this checkbox is hidden, but i saw it somewhere :)

summit’s picture

Hi,
set this to active if that's ok. With the option shown in #2 you can change affilliate setting for the nodes which are shown...but I have 110 pages of nodes..
How can I alter all nodes at once for not showing on all domains, but only on the primary domain.
When this means a MYSQL query. thats ok by me. Better of course a setting for it.

Thans a lot advance for your reply
Greeting, Martijn

summit’s picture

Status: Postponed » Active

Forgot to set this to active. Greetings, Martijn

agentrickard’s picture

Write an update hook.

function custom_update_7000() {
  db_delete('domain_access')
    ->condition('realm', 'domain_site')
    ->execute();
  node_access_needs_rebuild(TRUE);
}

After running this update, you will be prompted to rebuild node access.

summit’s picture

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

Hi,
Sorry to ask, but how do I get this update hook to "run". Do I need to add it to my Domain.install and than run update.php?
Thanks for your reply in advance!
Greetings, Martijn

summit’s picture

Hi,

I added this peace of code temporarily to domain.install

/**
 * Remove All Domains check for existing nodes
 */
function domain_update_7599() {
  db_delete('domain_access')
    ->condition('realm', 'my_site_url')
    ->execute();
  node_access_needs_rebuild(TRUE);
}

This worked.
After doing this update I deleted this peace of code again from domain.install.

Greetings,
Martijn

agentrickard’s picture

That may cause a problem if you have to upgrade the module later. Drupal increments the update count in the {system}.schema column.

The next release will have an update 7309 or so, which will fail to run since your schema version is now set to 7599.

Update hooks like yours need to go in a custom module, Now you need to update your {system} table.

summit’s picture

Hi, oeps sorry, which variable do I need to update please in the {system} table?
greetings, Martijn

agentrickard’s picture

Status: Active » Closed (works as designed)

{system}.schema

summit’s picture

Hi I changed back

schema_version 	smallint(6)    7306

Thanks for telling!
Greetings, Martijn