Tag: drupal 7
-
Drupal 7 schema & datetime
When working on db schemas in Drupal it’s good to know that syntax for datetime is somewhat changed. Before it (Drupal 6) it was: ‘type’ => ‘datetime’, now in Drupal 7 it’s: ‘mysql_type’ => ‘datetime’, // for mysql
-
Requiring files in Drupal 6 & 7
I have seen a lot of Drupal modules where requiring php files is done like this $module = ‘my_module’; require_once(DRUPAL_ROOT . ‘/’ . drupal_get_path(‘module’, $module) . ‘/test.php’); While this is totally right i still encourage you to use special function for this called “module_load_include“. module_load_include(‘php’, ‘my_module’, ‘test’);
-
Adding content programmatically in Drupal 7
Sometimes you really need to add content programmatically and here’s a little sample about the basics. $node = new stdClass(); // Set content type $node->type = ‘article’; // Prepare defaults node_object_prepare($node); // Define language (currently language neutral) $node->language = LANGUAGE_NONE; // Basic content $node->title = ‘Test’; $node->body[$node->language][0][‘value’] = ‘Body text’; // Example if using custom…