I'm trying to change a module to make it work with CCK FileField since this is compatible with a couple of import modules. Currently the module (ct_earth) shows a Google Earth view based on the attached (kml) files. The module uses a specific tpl file to accomplish this.

Name of the field I'm storing my kml files in is "kml". The original code in the tpl file looked like this:

<?php
$kml_path=array();
foreach ($node->files as $key) {
$kml_path[]=$key->filepath;
}

I've changed it to

<?php
$kml_path=array();
foreach ($node->field_kml as $key) {
$kml_path[]=$key->filepath;
}

which doesn't give an error but also doesn't populate a dropdown. If there's more then 1 file attached to the node, a dropdown is shown. When adding multiple files with the changed code I do get the dropdown with the numbers of rows equal to the numbers of files downloaded but without information. So, the question is what would be the correct way to retrieve the filefield data in the little piece of code above...

Thanks in advance.

Comments

quicksketch’s picture

I'm surprised you're not getting an error. Each value in $node->field_kml is an array, not an object.

$kml_path=array();
foreach ($node->field_kml as $file) {
  $kml_path[]=$file['filepath'];
}
pomgod’s picture

Status: Active » Closed (fixed)

Works perfect!