|
@@ -10,6 +10,7 @@
|
|
use Drupal\Core\Entity\EntityInterface;
|
|
use Drupal\Core\Entity\EntityInterface;
|
|
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
|
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
|
use Drupal\Core\Url;
|
|
use Drupal\Core\Url;
|
|
|
|
+use Drupal\Core\Link;
|
|
use Drupal\workflow\Entity\WorkflowManager;
|
|
use Drupal\workflow\Entity\WorkflowManager;
|
|
|
|
|
|
|
|
|
|
@@ -118,31 +119,48 @@ function edlp_corpus_node_view(array &$build, EntityInterface $entity, EntityVie
|
|
// build the array of relateds classified by page_type (taxonomy)
|
|
// build the array of relateds classified by page_type (taxonomy)
|
|
$relateds = array();
|
|
$relateds = array();
|
|
foreach ($nodes as $nid => $node) {
|
|
foreach ($nodes as $nid => $node) {
|
|
- $page_type = $node->get('field_page_type')->get(0)->getValue();
|
|
|
|
|
|
+ // $page_type = $node->get('field_page_type')->get(0)->getValue();
|
|
// dpm($page_type, 'page_type');
|
|
// dpm($page_type, 'page_type');
|
|
- $term = entity_load('taxonomy_term', $page_type['target_id']);
|
|
|
|
|
|
+ // $term = entity_load('taxonomy_term', $page_type['target_id']);
|
|
// dpm($term, 'term');
|
|
// dpm($term, 'term');
|
|
- $relateds[$term->getName()][] = $node->getTitle();
|
|
|
|
|
|
+ // $relateds[$term->getName()][] = $node->getTitle();
|
|
|
|
+ $url = Url::fromRoute('entity.node.canonical', ['node'=>$node->id()]);
|
|
|
|
+ $url->setOptions(array(
|
|
|
|
+ 'attributes' => array(
|
|
|
|
+ 'class' => ['ajax-link'],
|
|
|
|
+ 'data-drupal-link-system-path' => $url->getInternalPath()
|
|
|
|
+ )
|
|
|
|
+ ));
|
|
|
|
+ $link = Link::fromTextAndUrl(trim($node->getTitle()), $url);
|
|
|
|
+ // $relateds[$term->getName()][] = $link;
|
|
|
|
+ $relateds[] = $link->toRenderable();
|
|
}
|
|
}
|
|
// dpm($relateds, 'relateds');
|
|
// dpm($relateds, 'relateds');
|
|
|
|
|
|
// if relateds, build the sentence for display and the render array
|
|
// if relateds, build the sentence for display and the render array
|
|
if(count($relateds)){
|
|
if(count($relateds)){
|
|
- $relations = '<h3>' . t('This sound is about :') . '</h3><p>';
|
|
|
|
|
|
+ // $relations = '<h3>' . t('This sound is about :') . '</h3>';
|
|
|
|
|
|
- foreach ($relateds as $cat => $titles) {
|
|
|
|
- $relations .= '<span class="cat">' . $cat . ' :</span> ' . implode(', ', $titles) . ' | ';
|
|
|
|
- }
|
|
|
|
|
|
+ // foreach ($relateds as $cat => $titles) {
|
|
|
|
+ // // $relations .= '<span class="cat">' . $cat . ' :</span> ' . implode(', ', $titles) . ' | ';
|
|
|
|
+ // $relations[] =
|
|
|
|
+ // }
|
|
|
|
|
|
- $relations = preg_replace('/\s\|\s$/', '', $relations);
|
|
|
|
- $relations .= '</p>';
|
|
|
|
|
|
+ // $relations = preg_replace('/\s\|\s$/', '', $relations);
|
|
|
|
+ // $relations .= '</p>';
|
|
|
|
|
|
$build['relations'] = array(
|
|
$build['relations'] = array(
|
|
'#type'=>"container",
|
|
'#type'=>"container",
|
|
'#attributes'=>array(
|
|
'#attributes'=>array(
|
|
'class'=>'relations'
|
|
'class'=>'relations'
|
|
),
|
|
),
|
|
- "#markup"=> $relations,
|
|
|
|
|
|
+ 'title' => array(
|
|
|
|
+ "#markup"=> '<h3>' . t('This sound is about :') . '</h3>',
|
|
|
|
+ ),
|
|
|
|
+ 'content' => array (
|
|
|
|
+ '#theme' => 'item_list',
|
|
|
|
+ '#items' => $relateds,
|
|
|
|
+ ),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|