When I use this code to create a page node, the page gets created, but has the 'filtered_html' filter type even though I'm specifying 'php_code'. Because of this, the code I'm writing to the page is getting stripped out:

<?php
$path
= drupal_lookup_path('source', 'gsearch_results');
        if(!
$path){
                       
//this create the search results page if it doesn't exist
           
$node = new stdClass();
           
$node->type = "page";
           
$node->title = "Search Results";
           
$node->language = LANGUAGE_NONE;
           
$node->path = array('alias' => 'gsearch_results');
           
node_object_prepare($node);
           
$node->uid = 1;
           
$node->body[$node->language][0]['format'] = 'php_code';
           
$node->body[$node->language][0]['summary'] = 'UC Merced Site Search';
           
$node->body[$node->language][0]['value'] = '<gcse:search linktarget="_parent"
                queryParameterName="q_as">
                </gcse:search>'
;
           
$node = node_submit($node);
           
node_save($node);
            }
?>

What am I doing wrong?

Thanks in advance!
Bryan

Comments

What happens if you try and

What happens if you try and create such a node by hand?

It works just fine; I've

It works just fine; I've manually created the page for one of our many subsites, and it works.

I just checked the database

I just checked the database after creating a page with this code, and the filter type for the body is NULL. So-- the line that is setting the format has a problem...

EDIT: I figured it out. In our Drupal installations, the 'body' field is actually called 'field_page_body'. That's what I get for assuming the default name.