Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To embed CCK node create form into page/node in Drupal 6.x or other template file use the following code. Replace "store_review" with the machine-readable name of your content type (for example, Story nodes are "story" and "Store Reviews" are "store_review").
$node = new stdClass();
$node->type = 'store_review';
module_load_include('inc', 'node', 'node.pages');
$output = drupal_get_form('store_review_node_form', $node);
I spent several hours looking for solution. Here is the link to original source of the solution: http://drupal.org/node/261495
Alternative
if(!function_exists("node_object_prepare")) {
include_once(drupal_get_path('module', 'node') . '/node.pages.inc');
}
print node_add('store_review');
Comments
It doesn't work
I have a custom content-type name 'pembaca' to implement those technic. So, I copy node.tpl.php and then rename to node-pembaca.tpl.php.
Embed above code and make little change to:
Then it doesn't work.
Can you help me? What's wrong?
You have to print the output
The $output variable contains the rendering, but for it to actually appear on the page, you have to "print" it. Did you add a line somewhere similar to:
print $output;
Victor Kane
http://awebfactory.com
node form javascript in frontend
The example is working, but when I printing the node form in frontend, there are no scripts (js) that exists in admin pages,for open/close fields (I have printed the $closure variable, but it did'n help).
So, somebody knows how to include scripts for node form in frontend?
node form javascript in frontend
The example is working, but when I printing the node form in frontend, there are no scripts (js) that exists in admin pages,for open/close fields (I have printed the $closure variable, but it did'n help).
So, somebody knows how to include scripts for node form in frontend?
'$node' used in the above
'$node' used in the above code conflicts if you are trying to display the node form in another node page.
Caused me a lot of grief.
:)
Not sure
Using $node did not make a difference for me. The problem was solved by including as described above. I tested using $node and my form displayed fine and I did see any errors resulting from that in watchdog.