Drupal 附件(FileField)文件路径
Drupal中的什么函数获取文件附件路径?
编辑:系统部分上传模块提供的附件。但既然你提到了,可能还有另一种方法。也许我可以使用 FileField 模块实现可能的目标,因此如果您能告诉我如何获取 FileField 模块上传的文件的直接链接,这可能也会非常有帮助。
编辑2: 好吧,我将从我的主要和最终目标开始:
它是获得链接到文件的图像,我可以使用 CCK 模块管理该文件的可见性。
我正在一步一步地做这件事。现在我已经编写了一段代码来生成所需的图像,并将该图像添加到其中一种内容类型预告片中。我找到了一种方法来扭曲标签中的图像,并且我挖出了简单的附件网址。因此,我的下一步是从简单的上传附件升级到由 FileFields 添加的附件,并将所有 PHP 文档中看起来奇怪的 HTML 速度升级为管理精美的 CCK 字段。
- 如何获取上传文件FileFields的文件路径?
- 一些简单但同时丰富的教程,用于为 CCK 模块创建自定义字段。
What function in Drupal gets file attachment path?
Edit: the attachments provided by Upload module in system section. But since you mentioned there may be another way around it. Maybe I could achieve may goals using FileField module so if you could tell me how to get a direct link of a file uploaded by FileField module that may also be very helpful.
Edit 2:
Ok I will start from my main and final objective:
It is to get an image linking to a file which visibility I could be managed using CCK module.
I am doing this step by step. So now I have written a code which generates the needed image and I have added that image to one of content types teaser. I found a way to warp my image in a tag and I had dug up simple attachments url. So my next step is to advance from simple upload attachment to the one added by FileFields and from odd looking HTML pace in all PHP document into beautifully managed CCK field.
- How to fetch file path of a file uploaded FileFields?
- Some plain and at the same time rich tutorials for making custom fields for CCK module.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您尝试使用图像,因此应该使用 http://drupal.org/project/imagefield CCK 模块,用于将图像添加到指定的内容类型。之后,使用内容类型配置中的显示字段选项卡,您可以指定图像的呈现方式(作为链接、图像、带有节点链接的图像...)在预告片和身体视图中。
Since you are trying to use images, you should use http://drupal.org/project/imagefield CCK module in order to add images to specified content type. After that using the Display fields tab in Content type configuration you can specify how image would be presented (as a link, image, image with link to node...) both in teaser and body view.
核心上传模块的上传文件下方是否不会出现文件附件的直接链接?
Don't direct links of file attachments appear below the uploaded file for the core Upload module?
假设您知道如何获取包含文件附件的节点的
$node
对象,这非常简单:Upload (core)
其中
1
是文件的索引。上传可以让您上传多个文件,因此文件 2 的索引为2
等等。如果只有一个文件,则它始终为1
。upload_load()
API 参考。FileField
其中
field_filename
是您用于该字段的简称,0
是字段的索引。 CCK 字段允许您在一个字段中拥有多个值,因此0
将是第一个,1
将是第二个,依此类推。如果您只有一个值,它将始终为0
。注意:如果您想使用 FileField 的格式化程序获取 FileField 的渲染输出,您可以在节点模板中使用
$field_fieldname
,或者如果您想存储渲染的输出输出,您可以使用:content_format()
API 参考< /a>.Upload 是一个令人悲伤的小模块,在 Drupal 7 中已被 FileField 的核心实现完全取代。如果您可以选择使用 FileField,那么您应该这么做。
Assuming you know how to get the
$node
object for a node containing a file attachment, this is super easy:Upload (core)
Where
1
is the index of the file. Upload can let you upload more than one file, so file 2 would have an index of2
and so on. If there's only one file, it'll always be1
.upload_load()
API reference.FileField
Where
field_filename
is the short name you've used for the field, and0
is the index of the field. CCK fields let you have multiple values in one field, so0
would be the first,1
would be the second, etc. If you only have one value, it'll always be0
.Note: if you want to get the rendered output of the FileField using its formatters, you can just use
$field_fieldname
in your node template, or if you want to store the rendered output, you can use:content_format()
API reference.Upload is a sad little module, and has been completely replaced with a core implementation of FileField in Drupal 7. If you have the option to use FileField, you should.