$path='/home/vhosts/yourwebroot';
chdir($path);
require_once './includes/bootstrap.inc';
include_once './includes/common.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Get all node with language is EN
$results = views_get_view_result('view_node_en');
$max = 2000;
$count = 0;
foreach ($results as $node) {
if ($count == $max) break;
$nid = $node->nid;
$title = $node->node_title;
set_time_limit(20);
global $user;
$original_user = $user;
$user = user_load(1);
node_delete($nid);
$user = $original_user;
print 'Deleted -- '.$count."--".$nid."--".$title."\n";
$count = $count + 1;
}
- You must need global $user, because node_delete need user access node permission to delete nodes.
- views_get_view_result('view_node_en') this equal to SQL, return nodes with translate is EN

Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
ReplyDeleteSuper Bowl Commercials 2012
This is our experience when coding with drupal, so i note it here for friends, welcome man
ReplyDelete