Hello,
I'll try to explain my problem with my best english.
I want this module display information about tables 'files' in the module 'views'.
I have 3 tables :
- node (nid)
- filenode (fid, nid)
- files (fid, filepath, filename)
You will understand the table 'filenode' is a link between tables 'files' and 'node'.
With hook hook_views_data :
1st case (it works), valeur de filenode.fid is display (in views module)
function filenode_view_views_data()
{
$data['filenode']['table']['group'] = t('FileNode');
$data['filenode']['table']['join'] = array(
'node' => array (
'left_field' => 'nid',
'field' => 'nid',
),
);
$data['filenode']['fid'] = array(
'title' => t('FID'),
'help' => t('file id'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
return $data;
}
2nd case (it doesn't work) :
to display 'files' data (filename, filepath) in views module
function filenode_view_views_data()
{
$data['filenode']['table']['group'] = t('FileNode');
$data['filenode']['table']['join'] = array(
'files' => array (
'left_field' => 'fid',
'field' => 'fid',
),
'node' => array (
'left_field' => 'nid',
'field' => 'nid',
),
);
$data['filenode']['fid'] = array(
'title' => t('FID'),
'help' => t('file id'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
$data['filenode']['filename'] = array(
'title' => t('Filename'),
'help' => t('This is the filename.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
$data['filenode']['filepath'] = array(
'title' => t('Filepath'),
'help' => t('This is the filepath.'),
'field' => array(
'handler' => 'views_handler_field',
'click sortable' => TRUE,
),
'sort' => array(
'handler' => 'views_handler_sort',
),
'filter' => array(
'handler' => 'views_handler_filter_string',
),
'argument' => array(
'handler' => 'views_handler_argument_string',
),
);
return $data;
}
I implemented this code with information following documentation in
But it doesn't work, the generated query is not good.
user warning: Unknown column 'filenode.filename' in 'field list' query: SELECT node.nid AS nid, node.title AS node_title, filenode.fid AS filenode_fid, filenode.filename AS filenode_filename, filenode.filepath AS filenode_filepath FROM node node LEFT JOIN filenode filenode ON node.nid = filenode.nid LIMIT 0, 10 in D:\projects\drupal\sites\all\modules\views\includes\view.inc on line 765.
anyone have an idea to help me ? yes, i need a medic...
Thanks,
good afternoon,
Philippe (from Belgium)
PS: maybe it's possible my english is very strange ...
Comments
You asigned column filename
You asigned column filename to table filenode but it's column in files
$data['filenode']['filename']
Thomas Narres
Keep the sunny side up
try: ...
try:
http://www.agileapproach.com/blog-entry/views-2-table-aliases-and-extra-...