I would like to have my module to create new nodes (page) when being installed and removing these pages on uninstall.
I tried the following with no success in my mymodule.install file:
<?php
function mymodule_install() {
$node = new stdClass(); // We create a new node object
$node->type = "page"; // Or any other content type you want
$node->title = "Your title goes jere";
$node->language = LANGUAGE_NONE; // Or any language code if Locale module is enabled. More on this below *
$node->uid = 1; // Or any id you wish
$node->path = array('alias' => 'your_node_path'); // Setting a node path
node_object_prepare($node); // Set some default values.
// Let's add standard body field
$node->body[$node->language][0]['value'] = 'This is a body text';
$node->body[$node->language][0]['summary'] = 'Here goes a summary';
$node->body[$node->language][0]['format'] = 'filtered_html'; // If field has a format, you need to define it. Here we define a default filtered_html format for a body field
$node = node_submit($node); // Prepare node for a submit
node_save($node); // After this call we'll get a nid
}
This code is cut n' paste from this page.
When I disable/enable the module, the page is not created (at least it does not appear in Content and in the node table of the database).
How should I do it please?