0

I have custom table with a field called image_id.

image_id is an integer which represents a file id of the managed_file table.

I've read many tutorials on how to expose this field to views, and how to make a join with the managed file table. All examples just show joins with node table, but none of them make joins with file_managed.

I tried something like this:

    $data['my_table']['table']['join'] = [
        'file_managed' => [
            'left_field' => 'fid',
            'field' => 'image_id',
        ],            
    ];

    $data['my_table']['image_id']['relationship'] = [
        'handler' => 'views_handler_relationship',
        'base'=>'file_managed',
        'field'=>'image_id',
        'label' => 'Managed files',            
    ];

Right now my field is exposed, but the relation with the file_managed table doesn't work. I can't see fields from the managed files table, therefore I can't render my images with all formatters available.

Please help me!

Mario Araque
  • 4,562
  • 3
  • 15
  • 25
Beto Aveiga
  • 3,466
  • 4
  • 27
  • 39
  • why dont you join two tables with your column so that it will appear in your relation using http://www.sitepoint.com/exposing-tables-views-drupal-7/ – Viswanath Polaki May 28 '15 at 04:44
  • I read that tutorial between many others. I don't get your point. I'm trying to join my_table with file_managed, using image_id and fid, respectively. I can't do it, seems simple but it's not working. Thanks. – Beto Aveiga May 28 '15 at 19:31

0 Answers0