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: How To Renew Site Nodes

Submitted by on February 22, 2012 – 8:35 amNo Comment

You may need to resave nodes on your site in the following cases:

  • You need to re-create a teaser which is generated automatically  when saving a node after a number of symbols in that teaser has been changed.
  • You need to generate all values of calculated CCK fields for all nodes after installation of CCK Computed Field module.
  • XML Sitemap module shows incorrect paths (system paths (like ‘node/123′) instead of friendly URLs (like ‘/sohranit-statiu’)) after manipulations with URL in Pathauto or Path modules. When nodes are resaved, XML Sitemap uses friendly URLs instead of system ones.

Solution:

Note: if you use this code, ‘modified’ date will be changed (in contrast to ‘created’) for site nodes.

Please run the following PHP code on the site to renew (resave) site:

Drupal 5

The code resaves nodes of a certain 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 resaved.';
?>

Drupal 6

The code resaves 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 resaved.';
?>

Resave nodes of a certain type:

<?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.’ nodes .';
?>

Good luck!

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.