View source
<?php
function flashnode_views_tables() {
$tables['flashnode'] = array(
'name' => 'flashnode',
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'vid',
),
'right' => array(
'field' => 'vid',
),
),
'fields' => array(
'content' => array(
'name' => t('Flash node: Content'),
'sortable' => FALSE,
'notafield' => TRUE,
'option' => array(
'#type' => 'textfield',
'#size' => 10,
),
'handler' => 'flashnode_views_handler_field_content',
'help' => t('Display the flash content from this node. You can pass options using the flash node input filter syntax.'),
),
),
);
$tables['flashnode_filename'] = array(
'name' => 'files',
'join' => array(
'left' => array(
'table' => 'flashnode',
'field' => 'fid',
),
'right' => array(
'field' => 'fid',
),
),
'fields' => array(
'filepath' => array(
'name' => t('Flash node: Path'),
'sortable' => TRUE,
'help' => t('Display the file path for the flash content from this node.'),
),
),
'filters' => array(
'filepath' => array(
'name' => t('Flash node: Path'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
'help' => t('Filter based on the flash node file path.'),
),
),
);
return $tables;
}
function flashnode_views_handler_field_content($fieldinfo, $fielddata, $value, $data) {
$options = array();
if ($fielddata['options']) {
$options = array_map('trim', explode('|', $fielddata['options']));
}
$data = array(
'nid' => $data->nid,
);
foreach ($options as $option) {
$pos = strpos($option, '=');
$data_name = substr($option, 0, $pos);
$data_value = substr($option, $pos + 1);
$data[$data_name] = $data_value;
}
return flashnode_content($data);
}