Drupal: .htaccess Access Deny
August 21, 2014 – 7:59 am | No Comment

In this article I will tell how to forbid access to certain resources for some clients. The instructions will include descriptions of different directives.

Read the full story »
CSS Templates

Contain reviews and news about CSS Templates.

Freebies

Contain freebies such as icons, graphics, headers and images for your websites.

Fun Stuff

Contains other fun stuff for entertainment or interesting site showcase.

How-To

Contain technical elaborations on some specific workarounds or common tweak.

Joomla Templates

Contains reviews and news about Joomla templates.

Home » How-To

Drupal: Re-Save All Site Nodes

Submitted by on June 9, 2010 – 5:48 am3 Comments

This article is about re-saving all nodes on your Drupal-based site. You can wish to re-save nodes in the following cases:

  • After number of symbols in teaser has been changed, you need create again teaser which is generated automatically when node saving.
  • You installed CCK Computed Field module and need to create again all values of CKK calculated fields for all nodes.
  • After operations with URL in Pathauto or Path module, XML Sitemap module shows paths incorrectly – it shows system paths (like ‘node/123′) instead of NC(like ‘/sohranit-statiu’). When re-saving, XML Sitemap module uses NC instead of the system paths.

 

Solution

Attention: Date Modified (NOT Date Created) will be changed for site documents when using this code .

To update (re-save) site nodes, you should run the following code on your site:

Drupal 5

The code re-saves nodes of a specified type.
<?php
//Change type here
$type = ‘book';
$result = db_query("SELECT nid FROM {node} where type=’%s’", $type);
$count = 0;
while ($current_node = db_fetch_array($result)){
set_time_limit(0);
$current_node_id = node_load($current_node["nid"]);
  node_save($current_node_id);
$count++;
}
echo ‘Done. ‘.$count.’ nodes were re-saved.';
?>

Drupal 6

The code re-saves all site nodes:

 
<?php
$result = db_query("SELECT nid FROM {node}");
$count = 0;
set_time_limit(0);
while ($current_node = db_fetch_array($result)) {
  node_save(node_load($current_node["nid"]));
echo $current_node["nid"].'<br />';
$count++;
}
echo ‘Done. ‘.$count.’ nodes were re-saved.';
?>

Re-save nodes of a specified kind:

 
<?php
$result = db_query("SELECT nid, type FROM {node}");
$count = 0;
set_time_limit(0);
while ($current_node = db_fetch_array($result)) {
if ($current_node["type"] == ‘og_group’) {
    node_save(node_load($current_node["nid"]));
echo $current_node["nid"].'<br />';
$count++;
}
}
echo ‘Done. ‘.$count.’ documents were re-saved.';
?>

3 Comments »

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.