Corrections Pods (sous-types custom-simple, sync pick→taxonomie), agenda accueil et gras/italique single
This commit is contained in:
93
index.php
93
index.php
@@ -88,7 +88,7 @@ $messages_labo = Timber::get_posts([
|
||||
$context['messages_labo'] = $messages_labo ?: [];
|
||||
$context['message_labo_link'] = thalim_en_url( get_category_link( thalim_cat_id('message-labo') ) );
|
||||
|
||||
// --- Agenda (médiation scientifique + séances de séminaire à venir) ---
|
||||
// --- Agenda (manifestations scientifiques + séances de séminaire + médiation à venir) ---
|
||||
$agenda_lang = thalim_current_language();
|
||||
// Catégories « agenda » résolues par slug (médiation + newsletter/gazette historiques)
|
||||
$mediation_cat_ids = array_values( array_filter( [
|
||||
@@ -107,6 +107,30 @@ $agenda_type_fields = [
|
||||
'type_media', 'type_captation', 'type_revue_collection', 'type_autre',
|
||||
];
|
||||
$now_str = date('Y-m-d H:i:s');
|
||||
$today = date('Y-m-d');
|
||||
|
||||
// Date d'événement d'un post : date_de_debut prioritaire, datetime (communications) en secours.
|
||||
$read_event_date = function ($post_id) {
|
||||
foreach (['date_de_debut', 'datetime'] as $key) {
|
||||
$val = get_post_meta($post_id, $key, true);
|
||||
if ($val && strpos($val, '0000-00-00') !== 0) return $val;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
// type_label : premier champ type_* rempli, sinon nom d'une catégorie du post présente dans $cat_ids.
|
||||
$agenda_type_label = function ($post_id, array $cat_ids = []) use ($agenda_type_fields) {
|
||||
foreach ($agenda_type_fields as $field) {
|
||||
$val = get_post_meta($post_id, $field, true);
|
||||
if ($val) return $val;
|
||||
}
|
||||
if ($cat_ids) {
|
||||
foreach (get_the_category($post_id) as $cat) {
|
||||
if (in_array($cat->term_id, $cat_ids)) return thalim_cat_name($cat);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
$make_agenda_item = function ($post, $raw_date, $type_label, $lieu, $link) use ($agenda_lang, $months_fr, $months_en) {
|
||||
$ts = strtotime($raw_date);
|
||||
@@ -124,6 +148,7 @@ $make_agenda_item = function ($post, $raw_date, $type_label, $lieu, $link) use (
|
||||
};
|
||||
|
||||
$agenda_items = [];
|
||||
$seen_ids = [];
|
||||
|
||||
// 1. Upcoming médiation scientifique posts
|
||||
$mediation_upcoming = Timber::get_posts([
|
||||
@@ -141,23 +166,51 @@ $mediation_upcoming = Timber::get_posts([
|
||||
],
|
||||
]);
|
||||
foreach ($mediation_upcoming as $mpost) {
|
||||
if (isset($seen_ids[$mpost->ID])) continue;
|
||||
$raw_date = get_post_meta($mpost->ID, 'date_de_debut', true);
|
||||
if (!$raw_date) continue;
|
||||
$type_label = '';
|
||||
foreach ($agenda_type_fields as $field) {
|
||||
$val = get_post_meta($mpost->ID, $field, true);
|
||||
if ($val) { $type_label = $val; break; }
|
||||
}
|
||||
if (!$type_label) {
|
||||
foreach (get_the_category($mpost->ID) as $cat) {
|
||||
if (in_array($cat->term_id, $mediation_cat_ids)) { $type_label = thalim_cat_name($cat); break; }
|
||||
}
|
||||
}
|
||||
$type_label = $agenda_type_label($mpost->ID, $mediation_cat_ids);
|
||||
$item = $make_agenda_item($mpost, $raw_date, $type_label, get_post_meta($mpost->ID, 'lieu', true) ?: '', get_permalink($mpost->ID));
|
||||
if ($item) $agenda_items[] = $item;
|
||||
if ($item) { $agenda_items[] = $item; $seen_ids[$mpost->ID] = true; }
|
||||
}
|
||||
|
||||
// 2. Upcoming séances de séminaire
|
||||
// 2. Upcoming manifestations scientifiques (colloques, journées d'études, communications,
|
||||
// soutenances…) — tout le sous-arbre « manifestations » SAUF les séminaires (on affiche
|
||||
// leurs séances, cf. bloc 3). date_de_debut ou datetime (communications) via event-date filter.
|
||||
$manif_exclude = array_values( array_filter( [ thalim_cat_id('seminaires'), thalim_cat_id('seance') ] ) );
|
||||
$manif_upcoming = Timber::get_posts([
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => -1,
|
||||
'tax_query' => [
|
||||
'relation' => 'AND',
|
||||
[
|
||||
'taxonomy' => 'category',
|
||||
'field' => 'term_id',
|
||||
'terms' => [ thalim_cat_id('manifestations') ],
|
||||
'include_children' => true,
|
||||
],
|
||||
[
|
||||
'taxonomy' => 'category',
|
||||
'field' => 'term_id',
|
||||
'terms' => $manif_exclude,
|
||||
'operator' => 'NOT IN',
|
||||
],
|
||||
],
|
||||
'thalim_event_date_filter' => [ 'from' => $today ],
|
||||
]);
|
||||
$manif_label_cats = array_values( array_filter( [
|
||||
thalim_cat_id('colloques'), thalim_cat_id('communications'), thalim_cat_id('soutenances'),
|
||||
] ) );
|
||||
foreach ($manif_upcoming as $mpost) {
|
||||
if (isset($seen_ids[$mpost->ID])) continue;
|
||||
$raw_date = $read_event_date($mpost->ID);
|
||||
if (!$raw_date) continue;
|
||||
$type_label = $agenda_type_label($mpost->ID, $manif_label_cats);
|
||||
$item = $make_agenda_item($mpost, $raw_date, $type_label, get_post_meta($mpost->ID, 'lieu', true) ?: '', get_permalink($mpost->ID));
|
||||
if ($item) { $agenda_items[] = $item; $seen_ids[$mpost->ID] = true; }
|
||||
}
|
||||
|
||||
// 3. Upcoming séances de séminaire
|
||||
$seances_upcoming = Timber::get_posts([
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 8,
|
||||
@@ -173,12 +226,13 @@ $seances_upcoming = Timber::get_posts([
|
||||
],
|
||||
]);
|
||||
foreach ($seances_upcoming as $seance) {
|
||||
if (isset($seen_ids[$seance->ID])) continue;
|
||||
$raw_date = get_post_meta($seance->ID, 'date_de_debut', true);
|
||||
if (!$raw_date) continue;
|
||||
$link = thalim_get_seance_link($seance->ID);
|
||||
$label = $agenda_lang === 'en' ? 'Seminar session' : 'Séance de séminaire';
|
||||
$item = $make_agenda_item($seance, $raw_date, $label, get_post_meta($seance->ID, 'lieu', true) ?: '', $link);
|
||||
if ($item) $agenda_items[] = $item;
|
||||
if ($item) { $agenda_items[] = $item; $seen_ids[$seance->ID] = true; }
|
||||
}
|
||||
|
||||
// Sort merged list by date, keep 5 soonest
|
||||
@@ -199,16 +253,7 @@ if (empty($agenda_items)) {
|
||||
foreach ($fallback as $fpost) {
|
||||
$raw_date = get_post_meta($fpost->ID, 'date_de_debut', true);
|
||||
if (!$raw_date) continue;
|
||||
$type_label = '';
|
||||
foreach ($agenda_type_fields as $field) {
|
||||
$val = get_post_meta($fpost->ID, $field, true);
|
||||
if ($val) { $type_label = $val; break; }
|
||||
}
|
||||
if (!$type_label) {
|
||||
foreach (get_the_category($fpost->ID) as $cat) {
|
||||
if (in_array($cat->term_id, $mediation_cat_ids)) { $type_label = thalim_cat_name($cat); break; }
|
||||
}
|
||||
}
|
||||
$type_label = $agenda_type_label($fpost->ID, $mediation_cat_ids);
|
||||
$item = $make_agenda_item($fpost, $raw_date, $type_label, get_post_meta($fpost->ID, 'lieu', true) ?: '', get_permalink($fpost->ID));
|
||||
if ($item) $agenda_items[] = $item;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user