ajax loading of edlp studio from custom block link ok
also refactored page layout for better display of footer
This commit is contained in:
@@ -1,12 +1,57 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
use \Drupal\Core\Url;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
function template_preprocess_edlp_chutier_ui(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder($vars['entity_type']);
|
||||
// $vars['content'] = $view_builder->view($vars['entity'], $vars['view_mode']);
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$vars['documents'] = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['document_nodes'] as $node){
|
||||
// get the url
|
||||
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], ['absolute' => TRUE]);
|
||||
// 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);
|
||||
}
|
||||
// get the title
|
||||
$title = $node->getTitle();
|
||||
if(!$title) continue;
|
||||
$trunc_title = Unicode::truncate($title, 30, true, true);
|
||||
// classes
|
||||
$classes = array('audio-link', 'ajax-link');
|
||||
// get the entries
|
||||
$entrees = '';
|
||||
foreach ($node->get('field_entrees')->getValue() as $key => $term) {
|
||||
$entrees .= '<span class="entree" tid="'.$term['target_id'].'"></span>';
|
||||
}
|
||||
// build the link
|
||||
$vars['documents']['#items'][] = array(
|
||||
'#prefix' => '<div class="entrees">'.$entrees.'</div>',
|
||||
'#title' => $trunc_title,
|
||||
'#type' => 'link',
|
||||
'#url' => $url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $url->getInternalPath(),
|
||||
'audio_url' => $son_url,
|
||||
'nid' => $node->id(),
|
||||
// 'tid' => $entrees[mt_rand(0, count($entrees) - 1)],
|
||||
// 'entries_size' => count($entrees),
|
||||
'class' => $classes,
|
||||
'title'=>$title,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_compositions_ui(&$vars){
|
||||
function template_preprocess_edlp_composition_ui(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_studio_ui(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user