I'm trying to post a node add form for my cck type in Drupal 6. So as I did in drupal 5 I did this: print node_add('contenttype');

But that results in Fatal error: Call to undefined function node_add(). After debugging for xx hours I've found out it will work for ONE page load after I clear the cache using the devel module(devel/cache/clear). Then after the form has been rendered once it suddenly can't find the node_add function..

Comments

wla_g’s picture

You will have to do it similarly like in the following code snippet

   if( ! function_exists("node_object_prepare")) { 
      include_once(drupal_get_path('module', 'node') . '/node.pages.inc');
   }

but I haven't looked up if your mentioned function is located in the same file. That you have to find yourself.

Regards
Werner

nilashis’s picture

@tuti - what is the final code that worked for you?

Something like this?

function my_block_view() {
	  $block = array();
	 
	  if( ! function_exists("node_object_prepare")) { 
		include_once(drupal_get_path('module', 'node') . '/node.pages.inc');
		
	  }
          $block = drupal_render(node_add('stories'));
	 
	  return $block;
	}