drupal_execute填充图像字段
如何使用drupal_execute填充图像字段值。
例如我的内容类型(测试)有两个附加字段 1. 照片(图像提交), 2. phid (文本字段)
用于 phid $form_state['values']['field_phid'][0]['value'] ='14';
。如何填充图像字段类型的照片
How to populate image field value with drupal_execute.
for ex my content type (test) has two additional fields
1. photo (image filed),
2. phid (text field)
for phid $form_state['values']['field_phid'][0]['value'] ='14';
. how to populate photo which is image field type
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果文件已经上传到 Drupal 并具有文件 ID (fid),那么您可以执行“
如果文件尚未上传”则要棘手得多。您首先需要以编程方式创建该文件。我无法立即引导您完成它,但寻找有关如何完成的模板的好地方是服务模块的 file_service.inc 中的 file_service_save() 函数:
http://drupalcode.org/viewvc/drupal/contributions/modules/services/services/file_service/file_service.inc?revision=1.1.2.7.2.3&view=markup& ;pathrev=DRUPAL-6--2-2
需要明确的是:我并不是说您将使用 file_service_save() 来完成上传,而是该代码向您展示了需要做什么。它将向您展示如何使用 file_save_data() 将文件保存到服务器,将文件记录到 Drupal“文件”表,然后调用 hook_file_insert 通知其他模块文件已保存。
If the file is already uploaded to Drupal and has a file ID (fid) then you can just do
If the file isn't already uploaded it's a lot trickier. You'll first need to programmatically create the file. I can't walk you through it off-hand but a good place to look for a template as to how it should be done is the file_service_save() function in the Services module's file_service.inc:
http://drupalcode.org/viewvc/drupal/contributions/modules/services/services/file_service/file_service.inc?revision=1.1.2.7.2.3&view=markup&pathrev=DRUPAL-6--2-2
To be clear: I'm not saying you'll use file_service_save() to accomplish the upload, but that that code shows you what needs to be done. It will show you how to save the file to the server using file_save_data(), record the file to the Drupal "files" table, then call hook_file_insert to notify other modules that a file's been saved.
我找到了如下解决方案。我不知道优点和缺点,但它对我来说效果很好。
i found the solution as below . i dont know pros and cons but it works fine for me.