Flexinode - Grab Field Info
description
Intended for use with the flexinode.module, the following recyclable snippet allows you to extract the info of a specific flexinode field (for example an IMAGE) and allows you to use it in your custom-layout.tpl.php files.
Extremely useful for when you are theming flexinodes that contain Audio, Video, images or other fields that contain more than just text.
Thanks to Steve McKenzie from Raincity Studios for submitting this gem.
usage
One you have inserted the flexinode_field_info function in the template.php file in your active theme folder, you can re-use the same function for all your custom-layout.tpl.php files.
step 1 of 2
Using a text editor like Notepad.exe or equivalent, paste the following snippet into your template.php file. If your theme does not have a template.php file, you can create a new one, by simply copying the snippet into a file, saving it with the name template.php and uploading it to your active theme folder.
<?php
function flexinode_field_info($ctype, $label, $nid = 0) {
$sql = "SELECT f.field_id, f.ctype_id, f.label, d.textual_data, d.serialized_data FROM {flexinode_field} f ";
$sql .= "INNER JOIN {flexinode_data} d ON f.field_id = d.field_id WHERE f.ctype_id = %d AND f.label LIKE '%s'";
if ($nid) {
$sql .= " AND nid = ". $nid ." ";
}
$query = db_query($sql, $ctype, $label);
$result = db_fetch_object($query);
if ($result) {
return $result;
} else {
return;
}
}
?>Step 2 of 2
Use the following example snippet which illustrates how to extract the field info. for an image field when using flexinode.module.
<?php
$image = flexinode_field_info($ctype->ctype_id, "Image", $node->nid);
$image_data = unserialize($image->serialized_data);
$output = '<div class="flexinode_image"><img src="/'. $image_data->filepath. '" alt="'. $node->title . '" /></div>';
print $output;
?>notes
- This function works well with flexinode_node_type() and requires the Flexinode Module.

Useful but...
Okay... But say I want to:
1. get recent nodes from a taxonomy
(something like: http://drupal.org/node/30967)
2. get the title and a field from the flexinode and print that out...
How do I use this snippet?
marcopolo ---
Blog | Best Designed Drupal Websites | Share Trading |