By tonyp001 on
I was wondering if there was a way to create a node outside of the /node/add/type form?
You see, I'm writing a module that extends the users profile to include a new tab which gives them the ability to submit my modules node type. The goal was to hide all other fields and options besides the node body (I'd set the other options automatically). My idea was that I could make a "quick submit" form that only has the fields I need, but I'm not sure of the best way to do this is.
Does anyone have an idea?
I appreciate the input.
Comments
Create an object with the
Create an object with the data you want saved as a node and run it through node_submit() and node_save(). It'll take some experimentation, but it's possible.
Pretty easy to do. Make a
Pretty easy to do.
1. Make a regular Drupal form using the Form API.
2. In the _submit handler, collect the data you want to save into a $node object, and use node_save():
3. Eat cake :).
//edit
If you're not familiar with the Form API: http://drupal.org/node/262422
---
Yuriy Babenko
www.yubastudios.com
My Drupal tutorials: http://yubastudios.com/blog/tag/tutorials
---
Yuriy Babenko | Technical Consultant & Senior Developer
http://yuriybabenko.com
Thanks...
I'll give those a try. Again, thanks for the tips.
By the way, be warned when
By the way, be warned when creating content this way that you may be bypassing Drupal's security checks. It'd be wise to do some checks on your own using user_access(). So something like this:
Also, use node_submit() - it *will* make life easier.