A sort of "Quick Node Add" block
LiquidMethods - September 28, 2007 - 13:54
The functionality I am looking for (and haven't found yet!) is something that would allow me to create a block or a page that has just a few select fields for my users to fill out, and click submit and it would create a node. I don't want them to have to be in the admin, I want the "create content" admin page to remain untouched - this would be a completly seperate page or block, where I would have control over what fields they fill out to create the node.
Does anything like this exist, or what are ways I could do this?

possibilities
Of the top of my head, I believe there are many permutations of what is possible:
- create a role to restrict access for a certain group of users
- check/modify access permissions for creating an existing node type at /admin/user/access#module-node, create a page, or block etc with a link to adding that content type: /node/add/page
- create a custom content type using the cck module, and modify access, and add a link to the form as above
At the heart of it, what creates a node?
i think we're talking past each other... -- either I'm not understanding you or you're not understanding me :) I'm not sure why restricting access to anything would with what I'm trying to do.... let me put it another way:
How can I strip down a sort of "create node" code to just what it takes to create a new node? Imagine I just had a single filed (title) and a "submit" button and put this php code in a Block. For starters, that's all I want to do.
Ok, back to basics...
Let me explain this again from the start... Drupal creates nodes from pages that look like node/add/THIS node/add/THAT where "THIS and THAT" are the node type. From Drupal 5 on the functionality of CCK is in Drupal's core, so you can either edit the fields in a default node type, like "Page" or "Story" or create your own node type with your own fields.
For multiple reasons, I want to to be able to create a page (or a part of a page, IE "block" in Drupal terminology) that has fields that a user can fill out and click "submit" and the system will create a node based on the nodes they fill out. I want this to be its own entity separate from the default "node/add/*" pages for the following reasons:
1) I want to simplify the fields that the users have to see when they are creating a node
2) I want to be able to have different default values (sent through hidden input fields) depending on which form they are using - so that they can all be the same node type, just created with different values for certain fields depending on the "portal" they are creating the node from
3) As far as I know, there is no way to display the "node/add/*" pages as blocks
4) I want to control the actual HTML that outputs the fields themselves so that I can arrange them nicely on the page instead of just stacking them on top of each other. For example, I may wish to have first and last name as separate fields, but be on the same line.
This is a very basic funtionality when it comes down to it
Drupal is supposed to be so flexible, and it is - but if there is nothing in Drupal to address this hole, it really disappoints me.
I just can't believe no one out there knows any way to have users create a node other than the node/add/* page.
forms api and node_save
The learning curve can be a little formidable, especially as drupal is constantly evolving.
You are looking for the node_submit and node_save methods, and also need to read the forms api, to create a form for your block. Of course you could create a custom php form, however, it will not have the benefit of being automatically themed, and having a hidden anonymized form element added by default.
From my understanding (I am still learning) node_submit takes $node variable as an array and converts it to an object to prepare it or the node_save method. Be careful, if you wish to save the created date, have to save it to the node object in prepration for node_save, as node_submit will clear this field.
Usually, the keys of the $node array are similar to the column names of the node table, e.g. type, format, comment, uid, name, status, revision. For a related table, it is an array within an array, e.g. $node['taxonomy'] = array(4,1);
where 4 and 1 are the id's corresponding to the categories/tags in term_data that you want the node to be assigned to.
Also in the node_save function, the $node argument is passed by reference, so you can echo out the $node->id that is created.
node_save($node);
echo $node->id;
example of a php script using node_save is http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/devel/gener...
this script has since v5 been moved to devel_generate.module
use these modules to create a quick add node block
I hope I'm not misunderstanding, but I had almost the same challenge and managed my way with this solution :
- use form block module to make the add node form available as a block
- use form filter module to simplify the form by hidding unwanted fields