I am using Drupal 6.25 with Postgres 8.4. I want to create stories from backend. To which tables and columns should I insert values so that one story is shown on my drupal site?
-
Are you a drupal fresher? A direct db insert for a node is almost difficult.– niksmacCommented Apr 18, 2012 at 5:35
-
Yes I am a drupal fresher. My requirement is such that I have one client-server based opensource ERP. From that ERP, on a particular event, I need to put one story based upon data from that ERP. @NikhilMohan Yes I know that's difficult, but you haven't said that's impossible! Can anybody please suggest some way...– Sidharth BanerjeeCommented Apr 18, 2012 at 6:06
Add a comment
|
1 Answer
This is Drupal way to insert a new node from code.
<?php
// add node properties
$newNode = (object) NULL;
$newNode->type = '{NODE_TYPE}';
$newNode->title = '{NODE_TITLE}'
$newNode->uid = {USER_ID};
$newNode->created = strtotime("now");
$newNode->changed = strtotime("now");
$newNode->status = 1;
$newNode->comment = 0;
$newNode->promote = 0;
$newNode->moderate = 0;
$newNode->sticky = 0;
// add CCK field data
$newNode->field_{YOUR_CUSTOM_FIELD_1}[0]['value'] = '{DATA_1}';
$newNode->field_{YOUR_CUSTOM_FIELD_2}[0]['value'] = '{DATA_2}';
// save node
node_save($newNode);
?>
Best of luck with Drupal.
You will need to refer Creating Drupal 7.x modules
-
2Couple things, he's using Drupal 6.25 so drupal.org/node/231276 (Creating Drupal 6 Modules) will probably be more helpful that the D7 version, and not all CCK fields use 'value' so be careful there as well as knowing you can have multiple value fields so it's not always indexed to 0 either, but all in all a good start for sure Commented Apr 18, 2012 at 13:09
-
@Jimajamma Thanks. +1 for the CCK fields use 'value' thing.– niksmacCommented Apr 20, 2012 at 9:22