Skip to: site menu |main content

Welcome to my personal site. If You have any question or suggestion please feel free to contact me from contact page.

Advertisements

Contact me to place your Ads Here..

Powered by Drupal, an open source content management system

Syndicate

Syndicate content

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);
?>

Back to top

Related Pictures

Tags for Execute Drupal Php script for documents

Recent comments

InderSingh.com v1.2
(May 18, 2012)