added prog's child TOC menu #1459
This commit is contained in:
@@ -63,18 +63,31 @@ class ProgRessourceLink extends BlockBase {
|
||||
$build = [];
|
||||
$node = \Drupal::routeMatch()->getParameter('node');
|
||||
if ($node instanceof \Drupal\node\Entity\Node) {
|
||||
$nid = $node->id();
|
||||
// $title = $config["link_title"];
|
||||
$token_service = \Drupal::token();
|
||||
$title = $token_service->replace($config["link_title"], array('node' => $node));
|
||||
$url = Url::fromRoute("view.centre_de_ressources.page_1");
|
||||
$url->setRouteParameter("programme", $nid);
|
||||
$url->setOption('attributes', array("class"=>array('prog-ressources-link')));
|
||||
$build['prog_ressource_link'] = array(
|
||||
'#title' => $title,
|
||||
'#type' => 'link',
|
||||
'#url' => $url
|
||||
);
|
||||
// todo check if programme
|
||||
if($node->bundle() == 'programme'){
|
||||
// todo if yes get id
|
||||
$nid = $node->id();
|
||||
}else{
|
||||
// todo if not check if got field_programme
|
||||
$prog = $node->get('field_programme')->referencedEntities();
|
||||
if(count($prog)){
|
||||
$nid = $prog[0]->id();
|
||||
}
|
||||
}
|
||||
|
||||
if($nid){
|
||||
// $title = $config["link_title"];
|
||||
$token_service = \Drupal::token();
|
||||
$title = $token_service->replace($config["link_title"], array('node' => $node));
|
||||
$url = Url::fromRoute("view.centre_de_ressources.page_1");
|
||||
$url->setRouteParameter("programme", $nid);
|
||||
$url->setOption('attributes', array("class"=>array('prog-ressources-link')));
|
||||
$build['prog_ressource_link'] = array(
|
||||
'#title' => $title,
|
||||
'#type' => 'link',
|
||||
'#url' => $url
|
||||
);
|
||||
}
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
|
Reference in New Issue
Block a user