studio chutier is updating when documents added or removed, also added remove link in document list

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-12 18:33:48 +01:00
parent 119f89abca
commit 76dd9ddbc9
11 changed files with 253 additions and 107 deletions
@@ -3,6 +3,8 @@
use \Drupal\Core\Url;
use Drupal\Component\Utility\Unicode;
use Drupal\edlp_studio\Entity\Chutier;
function template_preprocess_edlp_chutier_ui(&$vars){
// dpm($vars);
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
@@ -34,23 +36,44 @@ function template_preprocess_edlp_chutier_ui(&$vars){
foreach ($node->get('field_entrees')->getValue() as $key => $term) {
$entrees .= '<span class="entree" tid="'.$term['target_id'].'"></span>';
}
//
// get the remove url (obviously as we are in chutier all contents actions are remove ;)
$remove_url = Chutier::getActionsUrl($node->id(), $vars['uid']);
// 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,
)
)
'#type' => 'container',
'entrees' => array(
'#type' => 'container',
'#attributes'=>['class'=>['entrees']],
'#markup'=>$entrees,
),
'link'=>array(
'#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,
),
),
),
'remove_link' => array(
'#title' => t("Chutier."),
'#type' => 'link',
'#url' => $remove_url,
'#options'=>array(
'attributes' => array(
'data-drupal-link-system-path' => $remove_url->getInternalPath()
),
),
),
);
}