开发者

Problem saving imagefield using hooks in Drupal 6

Here's my custom module; it basically fetches a file from a particular URL, saves it on temporary folder and then i want it to modify a cck field of type 'file' (field name being : field_video_thumb) :

function mymodule_nodeapi(&$node, $op) {
switch ($op) {
    case "update":
              $node->field_video_thu开发者_JAVA百科mb[0] = 
              field_file_save_file ($filename, array(),
              $files_path, FILE_EXISTS_REPLACE);
              // node_save($node);
            break;
    }
}

The problem i have here is that when i ucomment the 'node_save($node)' it works (but calls recursively of course) and removing it does not do anything.

I must be missing something really obvious but can't figure it out.


I have answered a similar question a while ago. There are some additional steps involved, but the most important difference to your attempt is to use the 'presave' operation of hook_nodeapi() instead of 'update', as update happens after the node has been updated.

(The code in the answer was taken from a utility class, so you would need to adjust it a bit to work from within a function.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜