home page of productions is ok!
This commit is contained in:
@@ -19,6 +19,13 @@ edlp_admin.add_page:
|
||||
title: 'New Page'
|
||||
appears_on:
|
||||
- view.content.page_1
|
||||
edlp_admin.edit_prod_menu:
|
||||
route_name: 'entity.menu.edit_form'
|
||||
route_parameters:
|
||||
menu: 'productions'
|
||||
title: 'Edit Production Menu'
|
||||
appears_on:
|
||||
- view.content.page_1
|
||||
edlp_admin.add_evenement:
|
||||
route_name: 'node.add'
|
||||
route_parameters:
|
||||
|
||||
@@ -14,10 +14,9 @@ function edlp_productions_theme($existing, $type, $theme, $path) {
|
||||
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
return array(
|
||||
'edlp_productions' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_productions.inc',
|
||||
'variables' => array(
|
||||
'hello' => NULL,
|
||||
'nodes_entities' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -7,12 +7,25 @@ function template_preprocess_edlp_productions(&$vars){
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
// $vars['next_event'] = array(
|
||||
// "#markup"=>"<h3>Prochaine Date</h3>",
|
||||
// "event"=>$view_builder->view($vars['next_event_node'], 'default')
|
||||
// );
|
||||
foreach($vars['nodes_entities'] as $node){
|
||||
switch($node->get('field_view_mode')->value){
|
||||
case "1":
|
||||
$vm = "image_2_columns";
|
||||
break;
|
||||
case "2":
|
||||
$vm = "image_1_columns";
|
||||
break;
|
||||
case "3":
|
||||
$vm = "text_1_column";
|
||||
break;
|
||||
};
|
||||
$vars['nodes'][] = array(
|
||||
'vm'=>$vm,
|
||||
'build'=>$view_builder->view($node, $vm)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,20 +25,23 @@ class ProductionsController extends ControllerBase {
|
||||
$result = $query->execute();
|
||||
// dpm($result);
|
||||
|
||||
$nids = [];
|
||||
foreach ($result as $id) {
|
||||
$menu_link = MenuLinkContent::load($id);
|
||||
// dpm($menu_link->getParentId());
|
||||
if($menu_link->getParentId() === ""){
|
||||
dpm($menu_link->getTitle());
|
||||
$path = $menu_link->getUrlObject()->getInternalPath();
|
||||
preg_match('/^node\/(\d+)$/', $path, $m);
|
||||
dpm($m[1]);
|
||||
}
|
||||
if($menu_link->getParentId() !== "") continue;
|
||||
|
||||
// dpm($menu_link->getTitle());
|
||||
$path = $menu_link->getUrlObject()->getInternalPath();
|
||||
preg_match('/^(node)\/(\d+)$/', $path, $m);
|
||||
// dpm($m);
|
||||
if($m[1] !== "node") continue;
|
||||
|
||||
$nids[] = ($m[2]);
|
||||
}
|
||||
|
||||
// TODO: loop through first level
|
||||
// TODO: load nodes
|
||||
// TODO: create items
|
||||
$this->nodes = entity_load_multiple('node', $nids);
|
||||
|
||||
// TODO: apply right display
|
||||
|
||||
}
|
||||
@@ -52,7 +55,7 @@ class ProductionsController extends ControllerBase {
|
||||
|
||||
return array(
|
||||
"#theme"=>'edlp_productions',
|
||||
"#hello"=>'Hello',
|
||||
"#nodes_entities"=>$this->nodes,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
{{ hello }}
|
||||
{% for node in nodes %}
|
||||
{{ node.build }}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user