<legend id='szcHl'><style id='szcHl'><dir id='szcHl'><q id='szcHl'></q></dir></style></legend>

        <bdo id='szcHl'></bdo><ul id='szcHl'></ul>
    1. <i id='szcHl'><tr id='szcHl'><dt id='szcHl'><q id='szcHl'><span id='szcHl'><b id='szcHl'><form id='szcHl'><ins id='szcHl'></ins><ul id='szcHl'></ul><sub id='szcHl'></sub></form><legend id='szcHl'></legend><bdo id='szcHl'><pre id='szcHl'><center id='szcHl'></center></pre></bdo></b><th id='szcHl'></th></span></q></dt></tr></i><div id='szcHl'><tfoot id='szcHl'></tfoot><dl id='szcHl'><fieldset id='szcHl'></fieldset></dl></div>

      <small id='szcHl'></small><noframes id='szcHl'>

      1. <tfoot id='szcHl'></tfoot>

        如何在使用 node_save($node) 创建图像时将图像附加到节点;

        时间:2023-06-22

            <tbody id='UYpuk'></tbody>
          • <bdo id='UYpuk'></bdo><ul id='UYpuk'></ul>

            <legend id='UYpuk'><style id='UYpuk'><dir id='UYpuk'><q id='UYpuk'></q></dir></style></legend>

            <small id='UYpuk'></small><noframes id='UYpuk'>

                <tfoot id='UYpuk'></tfoot>
                • <i id='UYpuk'><tr id='UYpuk'><dt id='UYpuk'><q id='UYpuk'><span id='UYpuk'><b id='UYpuk'><form id='UYpuk'><ins id='UYpuk'></ins><ul id='UYpuk'></ul><sub id='UYpuk'></sub></form><legend id='UYpuk'></legend><bdo id='UYpuk'><pre id='UYpuk'><center id='UYpuk'></center></pre></bdo></b><th id='UYpuk'></th></span></q></dt></tr></i><div id='UYpuk'><tfoot id='UYpuk'></tfoot><dl id='UYpuk'><fieldset id='UYpuk'></fieldset></dl></div>
                  本文介绍了如何在使用 node_save($node) 创建图像时将图像附加到节点;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您好,我正在使用 drupal 7,并尝试通过使用 php 解析数据并稍后使用 node_save($node) 创建节点来尝试从 xml 导入数据.

                  Hi i am working with drupal 7 and trying to import data from xml by parsing it using php and later on creating nodes with node_save($node).

                  到目前为止,我已经成功地从没有任何图像的 xml 中创建了节点.我想在导入时将图像附加到节点.

                  So far i have been succeeded to create nodes from xml without any images. I want to attach image to the node while i am importing it.

                  我知道 drupal 7 仍处于 alpha 6 中,但它很好.node_save($node) 函数与 drupal 6 中的几乎相同,但略有不同.

                  I know drupal 7 is still in alpha 6 but its good. node_save($node) function is almost same as in drupal 6 but little bit different.

                  好的,这是我的代码图像文件路径存储在一个变量中...任何帮助都会很棒...提前致谢

                  Ok here is my code image file path is stored in a variable...any help would be great..thanks in advance

                  function main($head, $txt) {
                    $nodes = array();
                    $nodes[0]['title'] = $head; // node name
                    $nodes[0]['body'] = $txt; // body text for the node
                    $nodes[0]['teaser'] = '<p>A node</p>';
                    $nodes[0]['timestamp'] = 1281765101;
                    $nodes[0]['format'] = 2;
                    make_nodes($nodes);
                  }
                  
                  function make_nodes($nodes) {
                    $new_node = $nodes[0];
                    $node = new stdClass();
                    $node->type = 'article';
                    $node->status = 1;
                    $node->uid = 1;
                    $node->title = $new_node['title'];
                    $node->promote = 1;
                    $node->created = $new_node['timestamp'];
                    $node->timestamp = $new_node['timestamp'];
                    $node->changed= $new_node['timestamp'];
                    $node->sticky = 0;
                    $node->language = 'en';
                    $node->body['und'][0]['format'] = 3;
                    $node->body['und'][0]['summary'] = $new_node['teaser'];
                    $node->body['und'][0]['value'] = $new_node['body'];
                    $node->revision = 0;
                    node_submit($node);
                    node_save($node);
                  }
                  

                  推荐答案

                  HI.在阅读了 10 个小时的文档后,我终于做到了……我在这里包含了我的代码

                  HI. After reading the documentation for 10 hours i finaly did it...i am including my code here

                  $uri = 'bird/bird_image.jpg';
                  $files =  new stdClass();
                  $files->uid = (isset($local_user->uid) && !empty($local_user->uid)?$local_user->uid:1);
                  $files->filename = 'bird.jpg';
                  $files->uri = $uri; 
                  $files->filemime = file_get_mimetype($uri);
                  $files->status = 1;
                  $files->timestamp = $new_node['timestamp'];
                  
                  file_copy($files);
                  

                  这就是如何上传文件并上传到drupal 7数据库

                  thats how one can upload file and to the drupal 7 database

                  这篇关于如何在使用 node_save($node) 创建图像时将图像附加到节点;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Drupal 模块将菜单项添加到主链接? 下一篇:将附件添加到 Jira 的 api

                  相关文章

                    <bdo id='oaAsu'></bdo><ul id='oaAsu'></ul>
                  <legend id='oaAsu'><style id='oaAsu'><dir id='oaAsu'><q id='oaAsu'></q></dir></style></legend>
                • <i id='oaAsu'><tr id='oaAsu'><dt id='oaAsu'><q id='oaAsu'><span id='oaAsu'><b id='oaAsu'><form id='oaAsu'><ins id='oaAsu'></ins><ul id='oaAsu'></ul><sub id='oaAsu'></sub></form><legend id='oaAsu'></legend><bdo id='oaAsu'><pre id='oaAsu'><center id='oaAsu'></center></pre></bdo></b><th id='oaAsu'></th></span></q></dt></tr></i><div id='oaAsu'><tfoot id='oaAsu'></tfoot><dl id='oaAsu'><fieldset id='oaAsu'></fieldset></dl></div>

                    <small id='oaAsu'></small><noframes id='oaAsu'>

                      <tfoot id='oaAsu'></tfoot>