function weight_old_nodes in Weight 7
Same name and namespace in other branches
- 5 weight.module \weight_old_nodes()
- 6 weight.admin.inc \weight_old_nodes()
Update the sticky value of existing nodes if they are enabled for weights. This ensures that they will sort correctly.
1 call to weight_old_nodes()
File
- ./
weight.admin.inc, line 113 - This module uses the sticky column of the node table to add weighting to nodes.
Code
function weight_old_nodes($weight_node_types = array()) {
if ($weight_node_types) {
$temp = new stdClass();
$temp->node_weight = variable_get('weight_default', 0);
drupal_set_message(t('Enabling weight for: !types, default weight: !default', array(
'!types' => implode(', ', $weight_node_types),
'!default' => $temp->node_weight,
)));
// Get default for non-sticky nodes;
$temp->sticky = 0;
_weight_encode($temp);
$not_sticky = $temp->sticky;
// Get default for sticky nodes;
$temp->sticky = 1;
_weight_encode($temp);
$is_sticky = $temp->sticky;
$count = db_update('node')
->fields(array(
'sticky' => $is_sticky,
))
->condition('type', $weight_node_types, 'IN')
->execute();
$count += db_update('node')
->fields(array(
'sticky' => $not_sticky,
))
->condition('type', $weight_node_types, 'IN')
->execute();
drupal_set_message(t('@count nodes weight enabled.', array(
'@count' => $count,
)));
}
}