Autonode CCK widget
This project is not covered by Drupal’s security advisory policy.
Autonode is a CCK widget that allows you to use any table in your database as a reference to create and refer nodes. The field asks for a key, which is looked up in the reference table you set up.
This might be a bit confusing at first, so let me illustrate what is being done:
suppose you have 4 cols in your reference table: unique key, a title, some text, and some number. You want to have a node created when you are referring to a not yet existing page using title as node title, text as node body, and ignore the number. You refer to a node identified by key="id137". id137 is typed into the autonode field, and when you submit the node. The module looks up the values:
unique key | title | sometext | somenumber -> id137 | "Title for id137" | "Mac is a PC" | 42
and creates the node with these values filled in, and includes the node id as reference. The current release is still a development version, however it should in principal work. Avoid reference tables where you have no unique id, or no title to assign.
There is a screencast on explaining the set-up here: https://blip.tv/file/498562. Its a bit quiet, sorry for that, i didn't want to wake up my folks.
How to set up the widget
Due to the nature of the widget (we need to select tables, then columns from these tables) the setup requires multiple steps. First you are presented with the basic settings on the widget setup page, no detailed options. After setting the reference node type (this will be autocreated) and the reference table (where the created reference node type gets its values from) you have to save the form. Go to configure again, and you will be presented with the detailed settings options for a) to chose a reference key from the table's columns, b) to select which columns from the reference table should go into which fields of the reference node type.
There is no option yet to select event, or location fields, but it is going to be done. Currently CCK and default fields are supported.
Note that there are several similar widgets available:
- nodereference shipped with CCK
Addnode is your choice if you want to offer a fillable input form for a reference on the same page you are writing the child node, add_n_reference gives you this after submission. Nodereference doesn't give you an option to create parent node if it doesn't exist, but for references only it is much more advanced than autonode.
To illustrate how it works imagine the following scenario (this is a scenario I actually wrote it for): you have a website where users are writing reviews about locations. These potential locations are in a reference table, that you import into your database. You have to do it this way, because you cant expect users set address, or even pick the coordinates on a map every time they want to write about a place.
In the database you identify the locations by lets say a code, or a name. This module helps you in adding a special code field to your review content types. This widget via the code field will then first check if the reference code put in exists already amongst your nodes - if yes, an autocomplete field helps you to select it, user writes the review, the post is getting referenced. If the reference code doesn't exist, that means that the user wants to write about some place not being yet written about on your site. If this is the case, then the module checks the code against your reference table, and if it exist it is going to take all the geographic data from there. If you dont have it, then the user receives an error that the location is not even in the reference table.