Hello,
I've created a view (with Views) which returns nodes that contain a FileField instance. In the "Live preview" on the bottom of the Edit View page, I see the proper URL for FileField instances. However, I've created a custom View template and when I am iterating through the results I am not getting the URL for the file in the FileField. Instead, I am only getting this info for the field:
[node_data_field_thumbnail_field_thumbnail_fid] => 1
[node_data_field_thumbnail_field_thumbnail_list] => 1
[node_data_field_thumbnail_field_thumbnail_data] => a:1:{s:11:"description";s:0:"";}
My questions are:
1. Is there an extra step I need to take to get the URL?
2. If so, why? I figure I was dealing with the same data as the default Views template.
Lastly, this may be ultimately a question for the Views guys, but they insist to ask here first.
Thanks for any help!
Comments
Comment #1
logik commentedComment #2
quicksketchWhich template are you using to theme the view (i.e. views-view.tpl.php, views-view-field.tpl.php, etc.)? I believe if you're working at the overall view level, the data hasn't yet been fully resolved. Normally Views will build up the necessary data just before it's rendered in the views-view-field.tpl.php files, so if you're working at a higher level that data isn't yet available, since things like the filepath are generated with an individual query.
To get this data, I'd suggest either theming at the field/row level of the view, or create a relationship to the File table, and add a field for File: Filepath.
Comment #3
quicksketchCrosspost
Comment #4
logik commentedThanks for the quick reply! That makes sense, I figured something like this was the case. Can you explain your last suggestion further? - "create a relationship to the File table, and add a field for File: Filepath."
Comment #5
quicksketchAdd a relationship for "Content: [Name of FileField]", this will join to the files table and make available the "File: Filepath" field, which you can use to construct the URL to the file by using file_create_url($filepath).
Comment #6
logik commentedOh - this is perfect. Thank you for your help!