Compare commits

..

5 Commits

Author SHA1 Message Date
Antoine M
48489aa9fa ENHANCE Pass current post type to post card template for improved context
All checks were successful
continuous-integration/drone/push Build is passing
2026-05-20 10:55:42 +02:00
Antoine M
26896828f4 REFACTOR Post card with external utilities function to handle permalink 2026-05-20 10:53:22 +02:00
Antoine M
79be66b060 REFACTOR Remove unused function 2026-05-20 10:52:36 +02:00
Antoine M
b18ba728d3 FIX Useless call to dynamiques content 2026-05-20 10:52:01 +02:00
Antoine M
17c66844f7 FIX body and html from overflow hidden to overflow clip 2026-05-20 09:39:06 +02:00
5 changed files with 173 additions and 111 deletions

View File

@ -96,6 +96,7 @@ function build_posts($request)
while ($posts_query->have_posts()) : $posts_query->the_post(); while ($posts_query->have_posts()) : $posts_query->the_post();
get_template_part('template-parts/components/cards/post-card', null, array( get_template_part('template-parts/components/cards/post-card', null, array(
'ID' => get_the_ID(), 'ID' => get_the_ID(),
'current_post_type' => $post_type
)); ));
endwhile; endwhile;
else : else :

View File

@ -17,17 +17,6 @@ function calculate_reading_time($content)
} }
function test()
{
$tags = get_terms(array(
'taxonomy' => 'etiquettes',
'hide_empty' => false,
));
return $tags;
}
function get_archive_page_icon_html($post_type) function get_archive_page_icon_html($post_type)
{ {
switch ($post_type) { switch ($post_type) {
@ -450,7 +439,7 @@ function is_a_collections_page()
$current_page_id = (int) get_queried_object_id(); $current_page_id = (int) get_queried_object_id();
if ($collection_parent_page_id === $current_page_id || $is_fond_archive_fonds_archives) { if ($collection_parent_page_id === $current_page_id) {
return true; return true;
} }
@ -464,3 +453,90 @@ function is_a_collections_page()
return false; return false;
} }
function carhop_get_post_card_link_according_to_post_datas($post_id, $card_args = [])
{
$post_id = (int) $post_id;
$has_external_link = $card_args['has_external_link'] ?? false;
$external_link = $card_args['external_link'] ?? false;
if ($has_external_link && $external_link !== '') {
return array(
'link' => $external_link,
'target' => '_blank',
'text' => $card_args['external_link_text'] ?? null,
'is_external' => true,
'has_valid_link' => true,
);
}
$post_type = get_post_type($post_id);
$link = get_the_permalink($post_id);
$target = '_self';
$text = null;
$is_external = false;
switch ($post_type) {
case 'analyses-etudes':
$type_analyse_etude = get_the_terms($post_id, 'type-analyse-etude')[0] ?? null;
if ($type_analyse_etude->slug === 'analyse') {
write_log("######");
$link_type = get_field('link_type', $post_id);
switch ($link_type) {
case 'pdf':
$pdf = get_field('pdf', $post_id);
if (is_array($pdf) && ! empty($pdf['url'])) {
$link = $pdf['url'];
$target = '_blank';
$is_external = true;
}
break;
case 'link':
$link_field = get_field('link', $post_id);
if (is_array($link_field) && ! empty($link_field['url'])) {
$link = $link_field['url'];
$target = '_blank';
$is_external = true;
}
break;
default:
$link = get_the_permalink($post_id);
break;
}
}
break;
case 'dbmob':
$maitron_url = get_field('maitron_url', $post_id);
write_log($maitron_url);
$link = $maitron_url ?? get_the_permalink($post_id);
$target = '_blank';
$text = 'Voir la notice';
break;
default:
$link = get_permalink($post_id) ?: '';
break;
}
return array(
'link' => $link,
'target' => $target,
'text' => $text,
'is_external' => $is_external,
'has_valid_link' => ($link !== ''),
);
}

View File

@ -4,11 +4,11 @@ a {
} }
html { html {
overflow-x: hidden; overflow-x: clip;
} }
body { body {
max-width: 100vw; max-width: 100vw;
overflow-x: hidden; overflow-x: clip;
} }
main { main {

View File

@ -11,14 +11,7 @@
<span><?php echo __('Rechercher', 'homegrade-theme__texte-fonctionnel') ?></span> <span><?php echo __('Rechercher', 'homegrade-theme__texte-fonctionnel') ?></span>
</button> </button>
</div> </div>
<?php
$lastRevue = $recent_posts = wp_get_recent_posts(array(
'numberposts' => 1,
'post_type' => 'revues',
'post_status' => 'publish',
));
$lastRevueUrl = get_permalink($lastRevue[0]['ID']);
?>
<ul class="search-module__suggestions"> <ul class="search-module__suggestions">

View File

@ -6,14 +6,7 @@ $showExcerpt = $args['show_excerpt'] ?? false;
$showTags = $args['showTags'] ?? true; $showTags = $args['showTags'] ?? true;
$has_external_link = $args['has_external_link'] ?? false;
$external_link = $args['external_link'] ?? null;
$external_link_text = $args['external_link_text'] ?? null;
$target = $has_external_link && ! empty($external_link) ? '_blank' : '_self';
$excerpt = get_the_excerpt($ID); $excerpt = get_the_excerpt($ID);
$link = ($has_external_link && ! empty($external_link)) ? $external_link : get_the_permalink($ID);
$has_post_thumbnail = has_post_thumbnail($ID); $has_post_thumbnail = has_post_thumbnail($ID);
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null; $thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
@ -35,32 +28,27 @@ $tags = get_the_terms($ID, 'etiquettes');
$description = get_field('description', $ID); $description = get_field('description', $ID);
$birth_death_date = get_field('birth_death_date', $ID); $birth_death_date = get_field('birth_death_date', $ID);
$card_link = carhop_get_post_card_link_according_to_post_datas($ID, $args);
$link = $card_link['link'];
$target = $card_link['target'];
$external_link_text = $card_link['text'];
$has_valid_link = $card_link['has_valid_link'];
$is_external = $card_link['is_external'];
if($current_post_type === 'analyses-etudes'){ $card_classes = 'card post-card post-card--' . sanitize_html_class((string) $current_post_type);
$type_analyse_etude = get_the_terms($ID, 'type-analyse-etude')[0] ?? null; $card_classes .= $has_post_thumbnail ? ' post-card--has-thumbnail' : '';
$card_classes .= ! $has_valid_link ? ' post-card--no-link' : '';
if($type_analyse_etude->slug === 'analyse'){
$link_type = get_field('link_type', $ID);
$target = '_blank' ;
switch($link_type){
case 'pdf':
$link = get_field('pdf', $ID)['url'] ?? '';
break;
case 'link':
$link = get_field('link', $ID)['url'] ?? '';
break;
default:
$link = get_the_permalink($ID);
break;
}
}
}
?> ?>
<a class="post-card post-card--<?php echo $current_post_type . ' ' . ($has_post_thumbnail ? 'post-card--has-thumbnail' : ''); ?> card" href="<?php echo esc_url($link); ?>" target="<?php echo $target; ?>"> <?php if ($has_valid_link) : ?>
<a class="<?php echo esc_attr(trim($card_classes)); ?>"
href="<?php echo esc_url($link); ?>"
target="<?php echo esc_attr($target); ?>"
<?php echo $is_external ? ' rel="noopener noreferrer"' : ''; ?>>
<?php else : ?>
<div class="<?php echo esc_attr(trim($card_classes)); ?>">
<?php endif; ?>
<?php if ($has_post_thumbnail) : ?> <?php if ($has_post_thumbnail) : ?>
<div class="post-card__thumbnail"> <div class="post-card__thumbnail">
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>"> <img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
@ -128,4 +116,8 @@ if($current_post_type === 'analyses-etudes'){
</div> </div>
</a> <?php if ($has_valid_link) : ?>
</a>
<?php else : ?>
</div>
<?php endif; ?>