Creating Drupal CCK Content Programmatically / Via API

I work with Drupal 6.x to create exercise / personal training programs, and I use CCK with Exercise and Program content types, where Program contains several header fields and a list of links to the exercise nodes it consists of. This works great, and I can manually create programs that work great. Now I want to create a module that can generate these programs automatically based on a number of algorithms developed by me, the process will look like this:

  1. Load all exercises into an array
  2. Download user personal data (previously entered)
  3. Set the most suitable exercises
  4. Create a new type of program content
  5. Save program

The exercise has a number of related attributes, and although I could do all of the above using SQL directly in tables, it would be rather complicated and would not seem correct. In step 1, I would like to load the exercises as an array of Exercise objects (node_load?), And then create a program object and save. Is such an approach like OO possible or do I have to resort to data manipulation directly?

+5
source share
4 answers

The best way to solve this problem is to write your own module to do this.

1 node_load ($ nid) 2 user_load ($ uid) 3 . 4/5. $ node= stdClass(); , node_save ($ node); $node → id ..

, node, print_r ($ node); , .

+5

Drupal "" . node node_save() , .

Node Export node ( CCK) .

+1

, "" .

, , "" .

, "" . , . (, ) , .

This will be dynamic and user-specific, and pay attention to the need to preload several programs.

Think.

0
source

All Articles