// Load up the node with files on it.$node = node_load(1);// Render the node.$rendered = node_view($node);// Later, decide you want a 'fresh' copy of the node.$fresh_node = node_load(1);// Save the fresh node.node_save($fresh_node);Now go and edit your file in Drupal, where has your uploaded file gone?
Well, the call to
Well, the call to
node_view means that file.module directly unsets the files that shouldn't be displayed. But, in my code, this node is effectively global, so when I call my second node load, it's not 'fresh' at all, I just get back a reference to the node that's had the file removed, so calling node_save on it was a very bad idea.$query = new EntityFieldQuery;
$result = $query
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'mytype')
->propertyCondition('title', $text)
->execute();
if (!empty($result['node'])) {
$nodes = node_load_multiple(array_keys($result['node']));
echo current($nodes)->body['und'][0]['safe_value'];
} $nid = $rs->nid;
$node = node_load($nid); <?php print $node->body['und'][0]['value'];?>
No comments:
Post a Comment