| 1 |
$Id: README.txt,v 1.2.2.1 2008/01/29 11:06:49 clemenstolboom Exp $
|
| 2 |
|
| 3 |
With node_factory a site developer can create nodes on the fly with little PHP knowledge.
|
| 4 |
|
| 5 |
function list
|
| 6 |
- node_factory_create_node : returns an array with nodetype items
|
| 7 |
- node_factory_set_value : sets a value of an element of the given array
|
| 8 |
- node_factory_save_node : saves the node
|
| 9 |
- node_factory_set_cck_value : helper function for CCK values
|
| 10 |
- node_factory_set_noderef_value : helper function for CCK node reference
|
| 11 |
|
| 12 |
Known Issues:
|
| 13 |
- cck node ref only works for 'Autocomplete' node ref type
|
| 14 |
- cck checkbox not working yet
|
| 15 |
|
| 16 |
Use Case Scenario:
|
| 17 |
1. You want to create a node 'child' when another node 'parent' is created
|
| 18 |
2. You want to create a node somewhere somehow.
|
| 19 |
|
| 20 |
Solution 1:
|
| 21 |
a. install workflow_ng and token module
|
| 22 |
b. create a workflow 'make child by parent' for event 'Content has been created'
|
| 23 |
c. add a condition 'is parent' and select the 'parent' content type
|
| 24 |
d. add an action 'create child' of type 'execute PHP code'
|
| 25 |
e. add the following PHP code to the action. Note the usage of token constructs like [node:title]
|
| 26 |
<code>
|
| 27 |
$edit= node_factory_create_node( 'child');
|
| 28 |
|
| 29 |
// setting default values
|
| 30 |
node_factory_set_value( $edit, 'title', "child [node:title]");
|
| 31 |
node_factory_set_value( $edit, 'body', 'a new child node');
|
| 32 |
|
| 33 |
node_factory_save_node( $edit);
|
| 34 |
</code>
|
| 35 |
f. create a node parent, submit and see the child node appearing.
|
| 36 |
|
| 37 |
Solution 2.
|
| 38 |
For this scenario I have not found a usage yet.
|
| 39 |
- Maybe place the number of current logged in users every 5 minute?
|
| 40 |
- Or randomly create a 'price node'.
|
| 41 |
- But this still sound more like 'use workflow_ng' too!!!
|
| 42 |
|
| 43 |
a. In this situation the token module, if installed, in not available (yet?)
|
| 44 |
so you need a little more PHP skills
|
| 45 |
b. add the following code somewhere in your template file
|
| 46 |
<code>
|
| 47 |
function my_function_to_create_a_node(){
|
| 48 |
$edit= node_factory_create_node( 'my_new_nodetype');
|
| 49 |
|
| 50 |
// setting default values
|
| 51 |
node_factory_set_value( $edit, 'title', "auto created");
|
| 52 |
node_factory_set_value( $edit, 'body', 'a new child node');
|
| 53 |
|
| 54 |
node_factory_save_node( $edit);
|
| 55 |
</code>
|
| 56 |
c. provide a trigger somewhere
|