Last active
December 20, 2015 07:58
-
-
Save shrop/6096753 to your computer and use it in GitHub Desktop.
Update a node object and save it (Drupal 7)
This file contains 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 | |
// Load a node with nid = 1000. | |
$node_nid = 1000; | |
$node = node_load($node_nid); | |
// Change the title of the node. | |
$node->title = 'New title'; | |
// Update the value of a field with the language property of the node object. | |
$node->field_custom[$node->$language][0]['value'] = 'New custom field data'; | |
// Set the revions property and save the updated node. | |
$node->revision = TRUE; | |
node_save($node); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment