Are the node/add/* pages the only things that can create a node?
WHAT I WANT
I want a way to create custom “add node” pages for my users. I want to be able to have multiple “add node” pages for the same CCK type (each with different default values).
WHY DO I WANT THIS?
Let’s say for example I have a webcomics Web site where I would want users to post pages of their comics which would be their own Comic Page CCK node type.
If they go to my custom Horror Comics Node Creation Page it would automatically fill in certain fields--such as automatically having “horror” selected as the genre. Creating a Webcomic Node from another one of these custom pages, like a “quick add” block at the bottom of a page, could have different options selected.
WHAT I DON’T WANT
I don’t want to hack the default node/add/* pages for several reasons—one of which is that the default page has lots of options that I would like to leave unmolested for admins. I would rather make my own page that presents the node creation fields how I want to present them. I also need these pages to have their own path (not just a different alias) and I would like to have the option to offer this Node Creation Page as a block instead of a page.
WHY HAVE I NEVER SEEN THIS ADDRESSED?
I’m thinking there’s probably a module out there that lets you make pages that create nodes when you submit them. If not, this seems like a pretty big oversight.

This is interesting but can
This is interesting but can you explain it a bit more?
- Currently you can put links for creating nodes of any types, such as /node/add/story, /node/add/blog, /node/add/node_type on any page you want, ok?
- For some reason you don't want to use different node types, but you want to use the same /node/add/node_type everywhere -- Why?
- You want /node/add/node_type to get different values depending on what page it is on? What kind of values? Taxonomy categories? A node title? Some content?
My pleasure! Let me respond
My pleasure! Let me respond to each part of your comment, to avoid confusion (because I’ve found, as I’ve asked people how to do this, that it is very easy to get confused)
Really? Do mean a link TO the add/node/node_type page, or do you mean you can actually put the fields for node creation on any page with a little “submit” button? Because that’s what I want.
I think you might be confused about this (though I could be wrong!). I don’t want to use different node types because, for most of the applications of this that I have (I’ve got no less than 3 sites I would use this on immediately if I knew how!) the nodes created by each of these different pages are really the same thing only with different values (such as the genre of comic book page they are posting, etc)
Edit: I realize that may not have answered your question. Basically, yes, I don't want to create a new CCK node type for each possible entry point--that's totally inefficient. Using my webcomics Web site example again, if a Comic Strip has a completely different set of default values (Comedy instead of Action / Adventure) then I would like you to be able to go to Node Add page specifically for that kind of comic, but each page adds the same CCK node type "Comic Page"
I understand a little better
I understand a little better now but not everything. For example why do you need a new form with a new Submit button if all you want is to create a node and you already have a link for that.
Also, consider the use of node types pre-CCK (and currently the Story and Page types). They are essentially the same but allow different workflows. Most importantly, they can restrict the applicable vocabularies and make it easier to create "sections" (a) with /node/add/node_type links and (b) by not overwhelming the user who posts something with taxonomy selection lists which contain all genres and all storylines.
I believe that when creating content node types offer some natural benefits. But never mind, things can always change.
Think of it like a sort of "quick add node" option
My problem isn't with whether or not it is a CCK node type or a default node type, I just want to have a way to make my own custom pages or blocks that create these nodes (page, story, or cck).
But you brought up a good point: Overwhelming the user--this is one of the main reasons I want to be able to create my own node add pages - I'd like to pick just 2 or 3 fields if I want--even if the node type has lots of different fields, I'd like to have some points of node creation that are very simple, and fill in most of the fields as hidden values, so my users only need to concern themselves with the unique data they are adding.
Here's another example: one thing I'd like to do is have a guestbook on my site where each new guestbook entry is a node - obviously the "add a guestbook entry" box would be at the bottom of the view displaying the guestbook nodes, but at the moment, there is nothing in Drupal I have found that lets someone display a "quick add node" box as a block.
Just a language
Just a language clarification. By "consider the use of non-CCK node types" I didn't mean "use them", I meant "think what they were used for".
Also, with the rise of CCK and node relationships using node reference fields I expect the number of node types to proliferate on many sites in the next year.
By the way, there is a module called Node Template (http://drupal.org/project/node_template) which might be adapted, at least for starting nodes with some information already present.
--------
Edited to add: You may also find this useful for writing a module to submit nodes within a form.
http://drupal.org/project/subform_element
http://drupal.org/node/133725 (A silly little example)
Check also how the taxonomy_defaults module assigns categories secretly. I don't understand PHP well enough to say more.
Modify the input form
One thing you could possibly do is modify the input form. This is a bit involved and I'm just pointing in the direction rather than going into detail how to do it, but it seems like it would work. Basically, you'd have one CCK node type as you wish but several node-type-edit.tpl.php files. In your template.php file, you conditionally load your tpl file based on whatever criteria you want. You could have one .tpl for admins and another for horror comics, etc. You'd put logic in the .tpl to pre-fill and hide certain fields.
If you have a field where it would be dangerous if someone was allowed to fill it in, you'd need to get into form_alter rather than just not printing the input field to prevent hacking, but this method works where you are just wanting to simplify the UI and nothing bad happens if some hacker force fills in a field that you're not displaying.
Michelle
--------------------------------------
My site: http://shellmultimedia.com
OH THIS SOUNDS PERFECT!
OH THIS SOUNDS PERFECT!
Cog, thank you for your contribution too of course, and I may end up doing that--but for someone who's never written a module, Michelle's option sounds like exactly what i'm looking for!
And yes, Michelle, I have very little interst in security--I'm not doing anything like taking credit cards or hosting top secret documents! lol, mostly these are artist portolio sites and Webcomics.
QUESTIONS...
1) So, does the node-type-edit.tpl.php take care of both the node add and the node edit?
2) How will I get a page to call these different node-type-edit.tpl.php pages?
My code
This is what I have in my template.php to load the custom input forms:
<?phpfunction phptemplate_node_form($form) {
switch ($form['#node']->type) {
case 'uprofile':
return _phptemplate_callback('node-uprofile-edit', array('form' => $form));
case 'event':
return _phptemplate_callback('node-event-edit', array('form' => $form));
default:
return theme_node_form($form);
}
}
?>
What this does is load "node-uprofile-edit.tpl.php" if the node type is uprofile, "node-event-edit.tpl.php" if the node type is event, and the default form for everything else.
In your case, you just have one node type, so you'd need to base your case statement on something else. That's the tricky part and I don't know specifically how you'd do it, so you'll need to do a little research. My guess is that you could get the referring page and base it on that. So if they click the link on page X you get one form and the link on page Y gets another form.
This does take care of both adding and editing.
Michelle
--------------------------------------
My site: http://shellmultimedia.com
Okay, just playing around
Okay, just playing around with it, to see if I could use your script to replace the "edit", I inserted this into the template.php of Garland (this is just a test site, so I'm using my admin theme):
// - from shellmultimedia.com
function phptemplate_node_form($form) {
switch ($form['#node']->type) {
case 'comic_page':
return _phptemplate_callback('node-comic_page-edit', array('form' => $form));
default:
return theme_node_form($form);
}
}
Then I have a file called node-comic_page-edit.php that just says:
<?phpecho "hello world";
So my expectation was that when I click "edit" on a Comic Page it would just say "hello world" instead of giving me the standard options for editing the page. It didn't it gave me all the regular fields, with no "hello world" - HOWEVER, when I click Create Content > Comic Page, it does remove all the fields, but just presents a blank page--"hello world" doesn't even show up in the source code.
Still, the fact that Submit Comic Page is now blank shows I'm starting to effect the right area!
It should work. Try
It should work. Try node-comic_page-edit.tpl.php
Probably it just didn't find the file.
We have "Hello World"!
Thank you! You rock--both of you!
Okay, well, where to begin!
I guess the first thing I need is to find the original edit page and node/*/edit fields so that i can start picking which ones to include in my node-comic_page-edit.tpl.php file. But where?
I'm excited!
Module
http://drupal.org/project/field_spotter is awesome for this.
Michelle
--------------------------------------
My site: http://shellmultimedia.com
Wow, okay, cool
I'll check that out! Thanks!
Field spotter question
Okay, I installed Field Spotter, and you're right--this thing is down right cool!
However, while it does show me the code that makes up fields, it hasn't helped me to find the code. For example, for one field it shows me <.?php print drupal_render($form['title']); ?> (dots added so the forum doesn't do its block quote thing) so I do a sitewide search for the character string <.?php print drupal_render($form['title']); ?> and dreamweaver tells me that no files contain that character string--or even a partial search, like drupal_render($form['title']) ...so, my question is--what file is this code in?
Thanks for all your help so far!
Andrew
Pointer needed
Is there a section that describes what to put in the tpl file for customizations?
You mean the available
You mean the available variables? You can find a lot of stuff here.
http://drupal.org/phptemplate -- Overview, look around
http://drupal.org/node/11812 -- variables for page.tpl.php and its page-something.tpl.php variants
http://drupal.org/node/11816 -- variables for node.tpl.php and its node-something.tpl.php variants
yes and no.
I have this in my properly named tpl file:All the fields render okay, except for the Preview and Submit Buttons.Please disregard. My file had not been uploaded via ftp. Once I re uploaded, the buttons appeared. Duh.
these things are easier in Dupal 6
Dreamweaver extension
subscribing
subscribing