Views join on custom table with file_managed table

339 views Asked by At

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!

0

There are 0 answers