audio links in entree index launch the audio player

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-09 10:52:51 +01:00
parent 6d1b3d33bb
commit 02155ede91
8 changed files with 146 additions and 15 deletions
@@ -54,7 +54,31 @@ function edlptheme_preprocess_edlp_productions(&$vars){
// dpm($vars);
}
function edlptheme_preprocess_node__player_cartel(&$vars){
function edlptheme_preprocess_node__enregistrement__index(&$vars){
$node = $vars['elements']['#node'];
$options = ['absolute' => TRUE];
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
$system_path = $url->getInternalPath();
// get the audio file url
$field_son_values = $node->get('field_son')->getValue();
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
$son_file = \Drupal\file\Entity\File::load($son_fid);
$son_url = null;
if($son_file){
$son_uri = $son_file->getFileUri();
$son_url = file_create_url($son_uri);
}
$vars['link_attributes'] = new Attribute(array(
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
'audio_url' => $son_url,
'nid' => $node->id(),
'class' => array('audio-link', 'ajax-link')
));
// dpm($vars['link_attributes']);
}
function edlptheme_preprocess_node__enregistrement__player_cartel(&$vars){
// dpm($vars);
// if transcript not empty
$url = Url::fromRoute('entity.node.canonical', ['node'=>$vars['node']->id()], array(