Tel: 91-98574-11333 | Mail: inderweb.com@gmail.com


Execute Drupal Php script for documents

<?php
if($_REQUEST['idebug']){
    for(
$i=0;$i<=10;$i++){
       
$node = new stdClass();
       
$node->type = 'story';   // Your specified content type
       
$node->created = time();
       
$node->changed = $node->created;
       
$node->status = 1;
       
$node->promote = 1;
       
$node->sticky = 0;
       
$node->format = 1;       // Filtered HTML
       
$node->uid = 1;      
       
$node->language = 'en';
       
$node->type="document_imported";
       
$node->field_pdf_upload[0]['value'] = "/path/to/pdf.pdf";
       
node_save($node);
    }
}
?>

Some dummy content for grabing filecontents into content node
$file will be parsed by php function
<?php
$node
= new stdClass();
$node->type = 'image';
$node->status = 1;
$node->uid = 1;
$node->title = basename($name, ".jpg");
$node->body = extract_body($file);
$node->created = time();
$node->changed = $node->created;
$node->promote = 1;
$node->sticky = 0;
$node->format = 1;
$node->language = 'en';

// custom node fields CCK
$node->field_date = array(
0 => array(
'value' => $date_value,
),
?>

<?php
$node
= new stdClass();
$node->title = 'title';
$node->body = 'Content body text';
$node->type = 'ccktype';
$filepaths = array('/filepath/demo1.jpg', '/filepath/demo2.jpg');
foreach (
$filepaths as $filepath) {
 
$field = field_file_save_file($filepath, array(), file_directory_path() .'/'. $directory);
 
$node->$field_name[] = $field;
}
$node = node_submit($node);
node_save($node);
?>