I'm using Views 7.x-3.8 and Drupal 7.
I've created cutom tables :
- youtube_video (with fields : vid, vtitle, description...)
- youtube_playlist (with fields : pid, ptitle, description...)
- youtube_video_playlist (with fields: vid, pid, weight)
I define my tables in Views with this hook_views_data() :
function mymodule_map_views_data() {
//The group name
$data['youtube_playlist']['table']['group'] = t('Youtube playlist');
$data['youtube_video']['table']['group'] = t('Youtube video');
//The base table
$data['youtube_video']['table']['base'] = array(
'field' => 'vid',
'title' => t('youtube video'),
'help' => t('youtube video should be related to youtube playlist.'),
'weight' => -10,
'defaults' => array(
'field' => 'vtitle',
),
);
//The join
$data['youtube_playlist']['table']['join']['youtube_video'] = array(
'left_table' => 'youtube_video_playlist',
'left_field' => 'pid',
'field' => 'pid',
);
// Allow this field to be used as a contextual filter.
$data['youtube_playlist']['pid'] = array(
'title' => t('playlist id'),
'help' => t('playlist id'),
'field' => array(
'handler' => 'views_handler_field_numeric',
'click sortable' => TRUE,
),
'argument' => array(
'handler' => 'views_handler_argument',
'name field' => 'title',
),
);
$data['youtube_video_playlist']['table']['join']['youtube_video'] = array(
'left_field' => 'vid',
'field' => 'vid',
);
//the fields description
$data['youtube_playlist']['ptitle'] = array(
'title' => t('youtube playlist title'),
'help' => t('youtube playlist title.'),
'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',
),
);
//the fields description
$data['youtube_playlist']['description'] = array(
'title' => t('youtube playlist description'),
'help' => t('youtube playlist description.'),
'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['youtube_video']['vtitle'] = array(
'title' => t('youtube video title'),
'help' => t('youtube video title.'),
'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['youtube_video']['vhash'] = array(
'title' => t('youtube video vhash'),
'help' => t('youtube video vhash.'),
'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've created a page view with my video informations, then - added the playlist title to the contextual filter - set the path to 'playlist/%'
This allows me to have a view that displays all videos from a playlist (filtered with a contextual filter). But to be usable, i would like to have a menu item "Playlist" and the submenus being AUTOMATICALLY all the playlists, when i create the view. Something like :
- Home
- Playlists
--playlist 1
--playlist 2
...
and when i click on playlist 1, i've got all the videos from that playlist 1
In menu section in views, I've tried to add menu tabs (and all the others, actually), but i have the message "A display whose path ends with a % cannot be a tab.". So it seems problematic to create (even only) menus with contextual filter.
Is it possible using only the standard view UI, or do i have to add some hooks or other logic ? If so do you have any lead.