Drupal CCK filefield variable access
Question
Just wondering can anyone tell me how to access the file field variable in drupal? I can access the rest of the node's variabels with the following php:
$node->field_event[0]['value'];
But I do not know how to access the content of a file field called field_pdf.
I know it is created with something like:
$node->field_pdf = array( array( 'fid' => $file->fid, 'title' => basename($file->filename), 'filename' => $file->filename, 'filepath' => $file->filepath, 'filesize' => $file->filesize, 'mimetype' => $mime, 'description' => basename($file->filename), 'list' => 1, ), );
I solved thie problem with the following snippet:
$node->field_pdf[0]['filepath'];
Hope this helps somebody.
j
Solution
I am not 100% sure I got what your doubt is, however on a node with a file_field (a series of PDF attachments in my case) the $node
object has a property called files
which structure is like this:
[files] => Array
(
[190] => stdClass Object
(
[fid] => 190
[uid] => 1
[filename] => attachmentname.pdf
[filepath] => sites/default/files/attachmentname_0.pdf
[filemime] => application/pdf
[filesize] => 295159
[status] => 1
[timestamp] => 1255855095
[nid] => 36644
[vid] => 36603
[description] => attachmentdescription
[list] => 1
[weight] => 0
)
I also suggest you install drupalforfirebug this is an awesome module that - in combination with firebug - allows you to see the structure of all your nodes / forms / user objects, etc... very handy!
HTH.
PS: If this is not what you are looking for, please specify in a comment how can I help better.