Last active
October 10, 2015 05:48
-
-
Save kalabro/3643917 to your computer and use it in GitHub Desktop.
Drupal 7: Update pathauto aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Use in devel/php or with drush scr. | |
* Compatible with http://drupal.org/project/redirect module. | |
*/ | |
// Some query. | |
$result = db_select('node', 'n') | |
->fields('n', array('nid')) | |
->condition('n.type', 'article') | |
->condition('n.status', 1) | |
->range(0, 300) | |
->orderBy('n.nid') | |
->execute(); | |
foreach ($result as $obj) { | |
$node = node_load($obj->nid); | |
$node->path = array('pathauto' => TRUE); | |
pathauto_node_update_alias($node, 'update'); | |
// Or pathauto_taxonomy_term_update_alias() for terms. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment