new mobile home #423
This commit is contained in:
@@ -22,12 +22,50 @@ function edlp_home_theme($existing, $type, $theme, $path) {
|
|||||||
// 'presentation_node' => NULL,
|
// 'presentation_node' => NULL,
|
||||||
// 'last_fil_node' => NULL,
|
// 'last_fil_node' => NULL,
|
||||||
// 'last_production_node' => NULL,
|
// 'last_production_node' => NULL,
|
||||||
'promoted_nodes' => array(),
|
'promoted_statics' => array(),
|
||||||
|
'promoted_prods' => array(),
|
||||||
'lastdocs_items' => NULL,
|
'lastdocs_items' => NULL,
|
||||||
'agenda_items' => NULL,
|
'agenda_items' => NULL,
|
||||||
// 'entrees_items' => NULL,
|
// 'entrees_items' => NULL,
|
||||||
'collection_link' => NULL,
|
'collection_link' => NULL,
|
||||||
|
'production_link' => NULL,
|
||||||
|
'agenda_link' => NULL,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_theme_suggestions_HOOK().
|
||||||
|
*/
|
||||||
|
function edlp_home_theme_suggestions_edlp_home_alter(array &$suggestions, array $variables) {
|
||||||
|
$is_mobile_domain = false;
|
||||||
|
|
||||||
|
// get domains from domain module
|
||||||
|
$domain_storage = \Drupal::entityTypeManager()->getStorage('domain');
|
||||||
|
$mobile_domain_id = 'm_encyclopediedelaparole_org';
|
||||||
|
// $mobile_domain = $domain_storage->load('m_encyclopediedelaparole_org');
|
||||||
|
global $base_root;
|
||||||
|
// get the current hostname (domain)
|
||||||
|
$current_hostname = preg_replace('/http:\/\/|https:\/\//i', '', $base_root);
|
||||||
|
// get the current domain
|
||||||
|
$current_domain = $domain_storage->loadByHostname($current_hostname);
|
||||||
|
|
||||||
|
if($current_domain){
|
||||||
|
// we are in a main domain
|
||||||
|
// $is_mobile_domain = ($current_domain->id() == $mobile_domain_id);
|
||||||
|
$current_domain_id = $current_domain->id();
|
||||||
|
}else{
|
||||||
|
// we are not in a main domain, so we look for an alias
|
||||||
|
$domain_alias_storage = \Drupal::entityTypeManager()->getStorage('domain_alias');
|
||||||
|
$alias = $domain_alias_storage->loadByHostname($current_hostname);
|
||||||
|
// dpm($alias, '$alias');
|
||||||
|
$current_domain_id = $alias->getDomainId();
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_mobile_domain = $current_domain_id == $mobile_domain_id;
|
||||||
|
|
||||||
|
if($is_mobile_domain){
|
||||||
|
array_unshift($suggestions, 'edlp_home__mobile');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,30 +7,33 @@ function template_preprocess_edlp_home(&$vars){
|
|||||||
// $term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
|
// $term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
|
||||||
// dpm($vars);
|
// dpm($vars);
|
||||||
|
|
||||||
// render the promoted_nodes
|
// render the promoted_statics and promoted_prods
|
||||||
$vars['nodes'] = array();
|
$promoteds = ['statics', 'prods'];
|
||||||
if(isset($vars['promoted_nodes'])){
|
foreach ($promoteds as $index => $p) {
|
||||||
foreach($vars['promoted_nodes'] as $node){
|
$vars['nodes_' . $p] = array();
|
||||||
if($node->hasField('field_view_mode')){
|
if(isset($vars['promoted_' . $p])){
|
||||||
switch($node->get('field_view_mode')->value){
|
foreach($vars['promoted_' . $p] as $node){
|
||||||
case "1":
|
if($node->hasField('field_view_mode')){
|
||||||
$vm = "image_2_columns";
|
switch($node->get('field_view_mode')->value){
|
||||||
break;
|
case "1":
|
||||||
case "2":
|
$vm = "image_2_columns";
|
||||||
$vm = "image_1_columns";
|
break;
|
||||||
break;
|
case "2":
|
||||||
case "3":
|
$vm = "image_1_columns";
|
||||||
$vm = "text_1_column";
|
break;
|
||||||
break;
|
case "3":
|
||||||
};
|
$vm = "text_1_column";
|
||||||
}else{
|
break;
|
||||||
$vm = 'default';
|
};
|
||||||
}
|
}else{
|
||||||
|
$vm = 'default';
|
||||||
|
}
|
||||||
|
|
||||||
$vars['nodes'][] = array(
|
$vars['nodes_' . $p][] = array(
|
||||||
'vm'=>$vm,
|
'vm'=>$vm,
|
||||||
'build'=>$node_view_builder->view($node, $vm)
|
'build'=>$node_view_builder->view($node, $vm)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +172,47 @@ function template_preprocess_edlp_home(&$vars){
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$vars['collection'] = render($collection);
|
$vars['collection_link_rendered'] = render($collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($vars['production_link'])){
|
||||||
|
$production = array(
|
||||||
|
'#type'=>"container",
|
||||||
|
'title'=>array(
|
||||||
|
'#prefix'=> '<h3>',
|
||||||
|
'#title' => t("Production"),
|
||||||
|
'#suffix' => '</h3>',
|
||||||
|
'#type' => 'link',
|
||||||
|
'#url' => $vars['production_link']['url'],
|
||||||
|
'#options'=>array(
|
||||||
|
'attributes' => array(
|
||||||
|
'data-drupal-link-system-path' => $vars['production_link']['internal_path'],
|
||||||
|
'class' => array('ajax-link'),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$vars['production_link_rendered'] = render($production);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($vars['agenda_link'])){
|
||||||
|
$agenda = array(
|
||||||
|
'#type'=>"container",
|
||||||
|
'title'=>array(
|
||||||
|
'#prefix'=> '<h3>',
|
||||||
|
'#title' => t("Agenda"),
|
||||||
|
'#suffix' => '</h3>',
|
||||||
|
'#type' => 'link',
|
||||||
|
'#url' => $vars['agenda_link']['url'],
|
||||||
|
'#options'=>array(
|
||||||
|
'attributes' => array(
|
||||||
|
'data-drupal-link-system-path' => $vars['agenda_link']['internal_path'],
|
||||||
|
'class' => array('ajax-link'),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$vars['agenda_link_rendered'] = render($agenda);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class HomeController extends ControllerBase {
|
|||||||
->condition('type', 'static');
|
->condition('type', 'static');
|
||||||
|
|
||||||
$promoted_nids = $query->execute();
|
$promoted_nids = $query->execute();
|
||||||
$contents["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
|
$contents["#promoted_statics"] = entity_load_multiple('node', $promoted_nids);
|
||||||
|
|
||||||
// then get production pages
|
// then get production pages
|
||||||
$query = \Drupal::entityQuery('node')
|
$query = \Drupal::entityQuery('node')
|
||||||
@@ -44,7 +44,7 @@ class HomeController extends ControllerBase {
|
|||||||
->condition('type', 'page');
|
->condition('type', 'page');
|
||||||
|
|
||||||
$promoted_nids = $query->execute();
|
$promoted_nids = $query->execute();
|
||||||
$contents["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
$contents["#promoted_prods"] = entity_load_multiple('node', $promoted_nids);
|
||||||
|
|
||||||
// presentation
|
// presentation
|
||||||
// $query = \Drupal::entityQuery('node')
|
// $query = \Drupal::entityQuery('node')
|
||||||
@@ -137,7 +137,7 @@ class HomeController extends ControllerBase {
|
|||||||
->condition('type', 'static');
|
->condition('type', 'static');
|
||||||
|
|
||||||
$promoted_nids = $query->execute();
|
$promoted_nids = $query->execute();
|
||||||
$renderable["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
|
$renderable["#promoted_statics"] = entity_load_multiple('node', $promoted_nids);
|
||||||
|
|
||||||
// then get production pages
|
// then get production pages
|
||||||
$query = \Drupal::entityQuery('node')
|
$query = \Drupal::entityQuery('node')
|
||||||
@@ -146,7 +146,7 @@ class HomeController extends ControllerBase {
|
|||||||
->condition('type', 'page');
|
->condition('type', 'page');
|
||||||
|
|
||||||
$promoted_nids = $query->execute();
|
$promoted_nids = $query->execute();
|
||||||
$renderable["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
$renderable["#promoted_prods"] = entity_load_multiple('node', $promoted_nids);
|
||||||
|
|
||||||
// last fil
|
// last fil
|
||||||
// $query = \Drupal::entityQuery('node')
|
// $query = \Drupal::entityQuery('node')
|
||||||
@@ -160,9 +160,9 @@ class HomeController extends ControllerBase {
|
|||||||
// $renderable["#last_fil_node"] = array('#markup'=>'En développement.');
|
// $renderable["#last_fil_node"] = array('#markup'=>'En développement.');
|
||||||
|
|
||||||
// agenda
|
// agenda
|
||||||
|
/*
|
||||||
$now = new DrupalDateTime('now');
|
$now = new DrupalDateTime('now');
|
||||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||||
|
|
||||||
$query = \Drupal::entityQuery('node')
|
$query = \Drupal::entityQuery('node')
|
||||||
->condition('status', 1)
|
->condition('status', 1)
|
||||||
->condition('type', 'evenement')
|
->condition('type', 'evenement')
|
||||||
@@ -172,7 +172,7 @@ class HomeController extends ControllerBase {
|
|||||||
|
|
||||||
$events = $query->execute();
|
$events = $query->execute();
|
||||||
$renderable['#agenda_items'] = entity_load_multiple('node', $events);
|
$renderable['#agenda_items'] = entity_load_multiple('node', $events);
|
||||||
|
*/
|
||||||
|
|
||||||
// Collection
|
// Collection
|
||||||
// TODO: get the link to mobile collection page
|
// TODO: get the link to mobile collection page
|
||||||
@@ -182,7 +182,19 @@ class HomeController extends ControllerBase {
|
|||||||
'internal_path' => $collection_url->getInternalPath(),
|
'internal_path' => $collection_url->getInternalPath(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Production
|
||||||
|
$production_url = Url::fromRoute('edlp_productions.productions');
|
||||||
|
$renderable['#production_link'] = array(
|
||||||
|
'url' => $production_url,
|
||||||
|
'internal_path' => $production_url->getInternalPath(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Agenda
|
||||||
|
$agenda_url = Url::fromRoute('edlp_agenda.agenda');
|
||||||
|
$renderable['#agenda_link'] = array(
|
||||||
|
'url' => $agenda_url,
|
||||||
|
'internal_path' => $agenda_url->getInternalPath(),
|
||||||
|
);
|
||||||
|
|
||||||
return $renderable;
|
return $renderable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,14 @@
|
|||||||
{# last_fil #}
|
{# last_fil #}
|
||||||
{# last_production #}
|
{# last_production #}
|
||||||
|
|
||||||
{% if nodes %}
|
{% if nodes_statics %}
|
||||||
{% for node in nodes %}
|
{% for node in nodes_statics %}
|
||||||
|
{{ node.build }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if nodes_prods %}
|
||||||
|
{% for node in nodes_prods %}
|
||||||
{{ node.build }}
|
{{ node.build }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -16,6 +22,14 @@
|
|||||||
{{ agenda }}
|
{{ agenda }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if collection %}
|
{% if collection_link_rendered %}
|
||||||
{{ collection }}
|
{{ collection_link_rendered }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if production_link_rendered %}
|
||||||
|
{{ production_link_rendered }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if agenda_link_rendered %}
|
||||||
|
{{ agenda_link_rendered }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -707,7 +707,9 @@ main[role="main"]{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.collection{
|
.collection-link,
|
||||||
|
.production-link,
|
||||||
|
.agenda-link{
|
||||||
h3{
|
h3{
|
||||||
@include content_titles;
|
@include content_titles;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -2032,7 +2034,7 @@ body.path-frontpage, body.path-productions{
|
|||||||
// p{margin: 0;}
|
// p{margin: 0;}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.node--view-mode-image-2-columns{
|
html:not(.is-mobile) &.node--view-mode-image-2-columns{
|
||||||
header{
|
header{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0; left:0;
|
bottom: 0; left:0;
|
||||||
|
|||||||
@@ -109,22 +109,28 @@ function edlptheme_theme_suggestions_taxonomy_term_alter(&$suggestions, $variabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
function edlptheme_preprocess_edlp_home(&$vars){
|
function edlptheme_preprocess_edlp_home(&$vars){
|
||||||
foreach($vars['nodes'] as &$node){
|
// render the promoted_statics and promoted_prods
|
||||||
switch($node['vm']){
|
$promoteds = ['statics', 'prods'];
|
||||||
case "image_2_columns":
|
// dpm($vars);
|
||||||
$cols = 4;
|
foreach ($promoteds as $index => $p) {
|
||||||
break;
|
foreach($vars['nodes_' . $p] as &$node){
|
||||||
case "image_1_columns":
|
switch($node['vm']){
|
||||||
$cols = 2;
|
case "image_2_columns":
|
||||||
break;
|
$cols = 4;
|
||||||
case "text_1_column":
|
break;
|
||||||
$cols = 2;
|
case "image_1_columns":
|
||||||
break;
|
$cols = 2;
|
||||||
default:
|
break;
|
||||||
$cols = 3;
|
case "text_1_column":
|
||||||
};
|
$cols = 2;
|
||||||
$node['cols'] = $cols;
|
break;
|
||||||
|
default:
|
||||||
|
$cols = 3;
|
||||||
|
};
|
||||||
|
$node['cols'] = $cols;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function edlptheme_preprocess_taxonomy_term__entrees__mobile_home(&$vars){
|
function edlptheme_preprocess_taxonomy_term__entrees__mobile_home(&$vars){
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<div class="grid">
|
||||||
|
|
||||||
|
{% if nodes_prods %}
|
||||||
|
{% for node in nodes_prods %}
|
||||||
|
<div class="col small-col-12 med-col-4 large-col-{{ node.cols }}">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ node.build }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if nodes_statics %}
|
||||||
|
{% for node in nodes_statics %}
|
||||||
|
<div class="col small-col-12 med-col-4 large-col-{{ node.cols }}">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ node.build }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if lastdocs %}
|
||||||
|
<div class="lastdocs-home col small-col-12 med-col-4 large-col-2">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ lastdocs }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if agenda %}
|
||||||
|
<div class="agenda col small-col-12 med-col-4 large-col-2">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ agenda }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if collection_link_rendered %}
|
||||||
|
<div class="collection-link col small-col-12 med-col-4 large-col-3">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ collection_link_rendered }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if production_link_rendered %}
|
||||||
|
<div class="production-link col small-col-12 med-col-4 large-col-3">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ production_link_rendered }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if agenda_link_rendered %}
|
||||||
|
<div class="agenda-link col small-col-12 med-col-4 large-col-3">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ agenda_link_rendered }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
@@ -17,8 +17,18 @@
|
|||||||
#}
|
#}
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
|
||||||
{% if nodes %}
|
{% if nodes_statics %}
|
||||||
{% for node in nodes %}
|
{% for node in nodes_statics %}
|
||||||
|
<div class="col small-col-12 med-col-4 large-col-{{ node.cols }}">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ node.build }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if nodes_prods %}
|
||||||
|
{% for node in nodes_prods %}
|
||||||
<div class="col small-col-12 med-col-4 large-col-{{ node.cols }}">
|
<div class="col small-col-12 med-col-4 large-col-{{ node.cols }}">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
{{ node.build }}
|
{{ node.build }}
|
||||||
@@ -43,10 +53,26 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if collection %}
|
{% if collection_link_rendered %}
|
||||||
<div class="collection col small-col-12 med-col-4 large-col-3">
|
<div class="collection_link col small-col-12 med-col-4 large-col-3">
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
{{ collection }}
|
{{ collection_link_rendered }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if production_link_rendered %}
|
||||||
|
<div class="production_link col small-col-12 med-col-4 large-col-3">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ production_link_rendered }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if agenda_link_rendered %}
|
||||||
|
<div class="agenda_link col small-col-12 med-col-4 large-col-3">
|
||||||
|
<div class="wrapper">
|
||||||
|
{{ agenda_link_rendered }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user