[support] How to import a node with file ?

Davide Michel 'ZioBudda' Morelli michel at ziobudda.net
Tue Nov 27 16:30:40 UTC 2007


Hi all. I need to import (from an  OLD proprietary CMS)
more and more notes that have a file field.

I have created my node type with a file CCK field, but I can not found 
how to create an entry for the file that was uploaded (like 
/tutorial/tutorialpsp3.zip).

I use this method where $l contains the info of my OLD node:

....
    $node = array();
            $node['type'] = "manuali_file";
            /* NOT WORKS
            $l1 = split("/",$l[11]);
            $i2 = count($l1);
            $node['field_allegati_manuale_upload'] = array(0 => 
array(    'description' => $l1[($i2-1)],
                                                        'filename' => 
$l1[($i2-1)],
                                                        'filepath' => 
$l[11],
                                                        'filesize' => 
$l[10]
                                            )          );
            */
           //$node['field_allegati_manuale'] = $l[11];
       
    $node['status'] = 0;
    $node['comment']=2;
    $node['promote'] = 0;
    $node['sticky'] = 0;
    $node['title']=$l[2];
    $node['body']=$l[2];
    $node['uid'] = 0;
    $node['status'] = 1;
    $d = split("/",$l[12]);
    $node['created']=mktime(0,0,0,$d[1],$d[0],$d[2]);
    $node['changed']=$node['created'];
   
    //Tiro fuori la id_categoria nuova
    $result = db_query("select tid from michel_import_old where id = 
".$l[7]);
    $t = db_fetch_object($result);
    $node['taxonomy'] = array($t->tid);
    $node = node_submit($node);
    node_save($node);

It works for normal node, But not for this one.

Tnx.

-- 
Michel 'ZioBudda' Morelli                       michel at ziobudda.net
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764  
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ajaxblog.it        			MSN: michel at ziobuddalabs.it                   
						JABBER: michel at gmail.com



More information about the support mailing list