domain_site_settngs + patch
home_mobile with entries
This commit is contained in:
@@ -23,7 +23,8 @@ function edlp_home_theme($existing, $type, $theme, $path) {
|
||||
// 'last_fil_node' => NULL,
|
||||
// 'last_production_node' => NULL,
|
||||
'promoted_nodes' => array(),
|
||||
'agenda_items' => NULL
|
||||
'agenda_items' => NULL,
|
||||
'entrees_items' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -13,3 +13,11 @@ edlp_home.home:
|
||||
_title: 'Home'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_home.home_mobile:
|
||||
path: '/home_m'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_home\Controller\HomeController::home_mobile'
|
||||
_title: 'Home'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_home(&$vars){
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
$node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
$term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
|
||||
// dpm($vars);
|
||||
|
||||
// render the promoted_nodes
|
||||
@@ -26,14 +27,14 @@ function template_preprocess_edlp_home(&$vars){
|
||||
|
||||
$vars['nodes'][] = array(
|
||||
'vm'=>$vm,
|
||||
'build'=>$view_builder->view($node, $vm)
|
||||
'build'=>$node_view_builder->view($node, $vm)
|
||||
);
|
||||
}
|
||||
|
||||
// render the presentation column
|
||||
// $vars["presentation"] = array(
|
||||
// "#type"=>"container",
|
||||
// "pres"=>$view_builder->view($vars["presentation_node"], 'default'),
|
||||
// "pres"=>$node_view_builder->view($vars["presentation_node"], 'default'),
|
||||
// "link"=> array(
|
||||
// '#title' => t('Visiter la collection sonore.'),
|
||||
// '#type' => 'link',
|
||||
@@ -48,7 +49,7 @@ function template_preprocess_edlp_home(&$vars){
|
||||
// render the last fil column
|
||||
// $vars["last_fil"] = array(
|
||||
// "#type" => "container",
|
||||
// // 'fil' => $view_builder->view($vars['last_fil_node'], 'teaser'),
|
||||
// // 'fil' => $node_view_builder->view($vars['last_fil_node'], 'teaser'),
|
||||
// 'title'=> array("#markup" => "<h2 class='title'>Dernier Fil</h2>"),
|
||||
// 'fil' => $vars['last_fil_node'],
|
||||
// // 'links' => array(
|
||||
@@ -80,7 +81,7 @@ function template_preprocess_edlp_home(&$vars){
|
||||
// render the last production column
|
||||
// $vars["last_production"] = array(
|
||||
// '#type' => 'container',
|
||||
// 'prod' => $view_builder->view($vars['last_production_node'], 'teaser'),
|
||||
// 'prod' => $node_view_builder->view($vars['last_production_node'], 'teaser'),
|
||||
// 'link'=> array(
|
||||
// '#title' => t('Voir toutes les productions.'),
|
||||
// '#type' => 'link',
|
||||
@@ -105,8 +106,25 @@ function template_preprocess_edlp_home(&$vars){
|
||||
);
|
||||
|
||||
foreach($vars['agenda_items'] as $node){
|
||||
$agenda['list']['#items'][] = $view_builder->view($node, 'teaser');
|
||||
$agenda['list']['#items'][] = $node_view_builder->view($node, 'teaser');
|
||||
}
|
||||
$vars['agenda'] = render($agenda);
|
||||
|
||||
if(isset($vars['entrees_items'])){
|
||||
$entrees = array(
|
||||
'#type'=>"container",
|
||||
// 'title'=>array(
|
||||
// '#markup'=>"<h3>".t("Entries")."</h3>",
|
||||
// ),
|
||||
'list'=> array(
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
),
|
||||
);
|
||||
foreach($vars['entrees_items'] as $term){
|
||||
$entrees['list']['#items'][] = $term_view_builder->view($term, 'home_mobile');
|
||||
}
|
||||
$vars['entrees'] = render($entrees);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,15 @@ namespace Drupal\edlp_home\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\workflow\Entity\WorkflowManager;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
|
||||
class HomeController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Display agenda as a page.
|
||||
* Display home as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
@@ -84,6 +86,153 @@ class HomeController extends ControllerBase {
|
||||
$events = $query->execute();
|
||||
$contents['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
|
||||
return $contents;
|
||||
}
|
||||
/**
|
||||
* Display agenda as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function home_mobile() {
|
||||
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$contents = array("#theme"=>'edlp_home');
|
||||
|
||||
// first get static pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'static');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// then get production pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'page');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// last fil
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'fil')
|
||||
// ->sort('created', 'DESC')
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $fil = $query->execute();
|
||||
// $contents["#last_fil_node"] = entity_load('node', array_pop($fil));
|
||||
// $contents["#last_fil_node"] = array('#markup'=>'En développement.');
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->range(0,5)
|
||||
->sort('field_date');
|
||||
|
||||
$events = $query->execute();
|
||||
$contents['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
|
||||
|
||||
// entrées
|
||||
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
$query = \Drupal::entityQuery('taxonomy_term')
|
||||
// ->sort('weight', 'DESC')
|
||||
// ->sort('name', 'DESC')
|
||||
->condition('vid', 'entrees');
|
||||
|
||||
$tids = $query->execute();
|
||||
// $terms = entity_load_multiple('taxonomy_term', $tids);
|
||||
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms);
|
||||
$terms = Term::loadMultiple($tids);
|
||||
|
||||
$ordered_terms = [];
|
||||
foreach ($terms as $term) {
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
|
||||
if($sid == 'generique_masque') continue;
|
||||
// translate the term
|
||||
$term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
|
||||
$name = $term->getName();
|
||||
$ordered_trans_terms[$name] = $term;
|
||||
}
|
||||
|
||||
ksort($ordered_trans_terms);
|
||||
|
||||
// dsm($terms);
|
||||
// foreach ($ordered_trans_terms as $name => $term) {
|
||||
// $tid = $term->id();
|
||||
//
|
||||
// $entree = array(
|
||||
// 'tid'=>$tid
|
||||
// );
|
||||
|
||||
// term link
|
||||
// $url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
|
||||
// $url->setOptions(array(
|
||||
// 'attributes' => array(
|
||||
// 'class' => ['term-'.$tid, 'term-link'],
|
||||
// 'tid'=>$tid,
|
||||
// 'selector' => 'entree-term-link-'.$tid,
|
||||
// 'data-drupal-link-system-path' => $url->getInternalPath()
|
||||
// )
|
||||
// ));
|
||||
// $entree['term_link'] = Link::fromTextAndUrl($name, $url);
|
||||
// index link
|
||||
// $url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
|
||||
// $url->setOptions(array(
|
||||
// 'attributes' => array(
|
||||
// 'class' => ['index-link', 'ajax-link'],
|
||||
// 'viewmode'=>'index',
|
||||
// 'tid'=>$tid,
|
||||
// 'selector' => 'entree-index-link-'.$tid,
|
||||
// 'data-drupal-link-system-path' => $url->getInternalPath()
|
||||
// )
|
||||
// ));
|
||||
// $entree['index_link'] = Link::fromTextAndUrl('index', $url);
|
||||
|
||||
// notice-link
|
||||
// $url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
|
||||
// $url->setOptions(array(
|
||||
// 'attributes' => array(
|
||||
// 'class' => ['notice-link'],
|
||||
// 'viewmode'=>'notice',
|
||||
// 'tid'=>$tid,
|
||||
// 'selector' => 'entree-notice-link-'.$tid,
|
||||
// 'data-drupal-link-system-path' => $url->getInternalPath()
|
||||
// )
|
||||
// ));
|
||||
// $entree['notice_link'] = Link::fromTextAndUrl('notice', $url);
|
||||
|
||||
// $entree['description'] = $term->get('description')->value;
|
||||
//
|
||||
// $entrees[] = $entree;
|
||||
// }
|
||||
|
||||
$contents['#entrees_items'] = $ordered_trans_terms;
|
||||
|
||||
// = array (
|
||||
// '#theme' => 'blockentrees',
|
||||
// '#entrees_items' => $entrees,
|
||||
// '#attached'=>array(
|
||||
// 'library' => array('edlp_corpus/corpus'),
|
||||
// 'drupalSettings' => array(
|
||||
// 'basepath' => base_path()
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,3 +6,7 @@
|
||||
{% endfor %}
|
||||
|
||||
{{ agenda }}
|
||||
|
||||
{% if entrees %}
|
||||
{{ entrees }}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user