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

arebos’s picture

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:

$node = new stdClass();
$node->type = 'pembaca';
module_load_include('inc', 'node', 'node.pages');
$output = drupal_get_form('pembaca_node_form', $node);

Then it doesn't work.
Can you help me? What's wrong?

victorkane’s picture

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;

variable’s picture

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?

variable’s picture

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?

abhid90210’s picture

'$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.
:)

rhawkins’s picture

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.