new mobile home #423
This commit is contained in:
@@ -22,12 +22,50 @@ function edlp_home_theme($existing, $type, $theme, $path) {
|
||||
// 'presentation_node' => NULL,
|
||||
// 'last_fil_node' => NULL,
|
||||
// 'last_production_node' => NULL,
|
||||
'promoted_nodes' => array(),
|
||||
'promoted_statics' => array(),
|
||||
'promoted_prods' => array(),
|
||||
'lastdocs_items' => NULL,
|
||||
'agenda_items' => NULL,
|
||||
// 'entrees_items' => 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');
|
||||
// dpm($vars);
|
||||
|
||||
// render the promoted_nodes
|
||||
$vars['nodes'] = array();
|
||||
if(isset($vars['promoted_nodes'])){
|
||||
foreach($vars['promoted_nodes'] as $node){
|
||||
if($node->hasField('field_view_mode')){
|
||||
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;
|
||||
};
|
||||
}else{
|
||||
$vm = 'default';
|
||||
}
|
||||
// render the promoted_statics and promoted_prods
|
||||
$promoteds = ['statics', 'prods'];
|
||||
foreach ($promoteds as $index => $p) {
|
||||
$vars['nodes_' . $p] = array();
|
||||
if(isset($vars['promoted_' . $p])){
|
||||
foreach($vars['promoted_' . $p] as $node){
|
||||
if($node->hasField('field_view_mode')){
|
||||
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;
|
||||
};
|
||||
}else{
|
||||
$vm = 'default';
|
||||
}
|
||||
|
||||
$vars['nodes'][] = array(
|
||||
'vm'=>$vm,
|
||||
'build'=>$node_view_builder->view($node, $vm)
|
||||
);
|
||||
$vars['nodes_' . $p][] = array(
|
||||
'vm'=>$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');
|
||||
|
||||
$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
|
||||
$query = \Drupal::entityQuery('node')
|
||||
@@ -44,7 +44,7 @@ class HomeController extends ControllerBase {
|
||||
->condition('type', 'page');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
||||
$contents["#promoted_prods"] = entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// presentation
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
@@ -137,7 +137,7 @@ class HomeController extends ControllerBase {
|
||||
->condition('type', 'static');
|
||||
|
||||
$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
|
||||
$query = \Drupal::entityQuery('node')
|
||||
@@ -146,7 +146,7 @@ class HomeController extends ControllerBase {
|
||||
->condition('type', 'page');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$renderable["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
||||
$renderable["#promoted_prods"] = entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// last fil
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
@@ -160,9 +160,9 @@ class HomeController extends ControllerBase {
|
||||
// $renderable["#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')
|
||||
@@ -172,7 +172,7 @@ class HomeController extends ControllerBase {
|
||||
|
||||
$events = $query->execute();
|
||||
$renderable['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
|
||||
*/
|
||||
|
||||
// Collection
|
||||
// TODO: get the link to mobile collection page
|
||||
@@ -182,7 +182,19 @@ class HomeController extends ControllerBase {
|
||||
'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;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,14 @@
|
||||
{# last_fil #}
|
||||
{# last_production #}
|
||||
|
||||
{% if nodes %}
|
||||
{% for node in nodes %}
|
||||
{% if nodes_statics %}
|
||||
{% for node in nodes_statics %}
|
||||
{{ node.build }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if nodes_prods %}
|
||||
{% for node in nodes_prods %}
|
||||
{{ node.build }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -16,6 +22,14 @@
|
||||
{{ agenda }}
|
||||
{% endif %}
|
||||
|
||||
{% if collection %}
|
||||
{{ collection }}
|
||||
{% if collection_link_rendered %}
|
||||
{{ collection_link_rendered }}
|
||||
{% endif %}
|
||||
|
||||
{% if production_link_rendered %}
|
||||
{{ production_link_rendered }}
|
||||
{% endif %}
|
||||
|
||||
{% if agenda_link_rendered %}
|
||||
{{ agenda_link_rendered }}
|
||||
{% 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{
|
||||
@include content_titles;
|
||||
text-align: center;
|
||||
@@ -2032,7 +2034,7 @@ body.path-frontpage, body.path-productions{
|
||||
// p{margin: 0;}
|
||||
}
|
||||
|
||||
&.node--view-mode-image-2-columns{
|
||||
html:not(.is-mobile) &.node--view-mode-image-2-columns{
|
||||
header{
|
||||
position: absolute;
|
||||
bottom: 0; left:0;
|
||||
|
||||
@@ -109,22 +109,28 @@ function edlptheme_theme_suggestions_taxonomy_term_alter(&$suggestions, $variabl
|
||||
}
|
||||
|
||||
function edlptheme_preprocess_edlp_home(&$vars){
|
||||
foreach($vars['nodes'] as &$node){
|
||||
switch($node['vm']){
|
||||
case "image_2_columns":
|
||||
$cols = 4;
|
||||
break;
|
||||
case "image_1_columns":
|
||||
$cols = 2;
|
||||
break;
|
||||
case "text_1_column":
|
||||
$cols = 2;
|
||||
break;
|
||||
default:
|
||||
$cols = 3;
|
||||
};
|
||||
$node['cols'] = $cols;
|
||||
// render the promoted_statics and promoted_prods
|
||||
$promoteds = ['statics', 'prods'];
|
||||
// dpm($vars);
|
||||
foreach ($promoteds as $index => $p) {
|
||||
foreach($vars['nodes_' . $p] as &$node){
|
||||
switch($node['vm']){
|
||||
case "image_2_columns":
|
||||
$cols = 4;
|
||||
break;
|
||||
case "image_1_columns":
|
||||
$cols = 2;
|
||||
break;
|
||||
case "text_1_column":
|
||||
$cols = 2;
|
||||
break;
|
||||
default:
|
||||
$cols = 3;
|
||||
};
|
||||
$node['cols'] = $cols;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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">
|
||||
|
||||
{% if nodes %}
|
||||
{% for node in nodes %}
|
||||
{% 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 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 }}
|
||||
@@ -43,10 +53,26 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if collection %}
|
||||
<div class="collection col small-col-12 med-col-4 large-col-3">
|
||||
{% if collection_link_rendered %}
|
||||
<div class="collection_link col small-col-12 med-col-4 large-col-3">
|
||||
<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>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user