Compare commits
No commits in common. "a50612cd58c05676569f08101994834ef48d2488" and "e16a195f03b2fa7e8706c223938f04e42e0617d6" have entirely different histories.
a50612cd58
...
e16a195f03
|
|
@ -7,13 +7,18 @@ add_action('rest_api_init', function () {
|
|||
-----------------*/
|
||||
|
||||
// ################ BUILD ARTISANS SEARCH RESULTS ################
|
||||
|
||||
// * BUILD MORE NEWS CARDS
|
||||
register_rest_route('metiers-patrimoine-datas/v1/build', '/artisans', array(
|
||||
'methods' => 'GET',
|
||||
'callback' => 'build_search_artisan_posts_cards',
|
||||
'permission_callback' => '__return_true',
|
||||
));
|
||||
});
|
||||
|
||||
|
||||
// ################ ARTISANS ################
|
||||
|
||||
|
||||
function build_search_artisan_posts_cards($request)
|
||||
{
|
||||
|
|
@ -61,10 +66,10 @@ function build_search_artisan_posts_cards($request)
|
|||
"meta_query" => $metaQuery,
|
||||
's' => $search_value,
|
||||
);
|
||||
$searchArtisans = new WP_Query($args);
|
||||
$newsPostsDatas = new WP_Query($args);
|
||||
|
||||
ob_start();
|
||||
foreach ($searchArtisans->posts as $key => $post) {
|
||||
foreach ($newsPostsDatas->posts as $key => $post) {
|
||||
|
||||
// continue en fonction
|
||||
$post_thumbnail = get_the_post_thumbnail($post->ID, 'full', array('class' => 'card-artisans__thumbnail')) ?? null;
|
||||
|
|
@ -89,7 +94,7 @@ function build_search_artisan_posts_cards($request)
|
|||
$html_template = ob_get_clean();
|
||||
|
||||
|
||||
if ($searchArtisans->found_posts === 0) {
|
||||
if ($newsPostsDatas->found_posts === 0) {
|
||||
ob_start();
|
||||
get_template_part(
|
||||
'template-components/artisans/artisan-search-no-results',
|
||||
|
|
@ -100,15 +105,49 @@ function build_search_artisan_posts_cards($request)
|
|||
}
|
||||
$response_data = array(
|
||||
'html_template' => $html_template,
|
||||
'total_posts_found' => $searchArtisans->found_posts,
|
||||
'total_posts_found' => $newsPostsDatas->found_posts,
|
||||
'active_page' => $activePage,
|
||||
'max_num_pages' => $searchArtisans->max_num_pages,
|
||||
'max_num_pages' => $newsPostsDatas->max_num_pages,
|
||||
);
|
||||
|
||||
|
||||
$response = new WP_REST_Response($response_data);
|
||||
|
||||
$response->set_status(200);
|
||||
// debugQueryTest( );
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
function debugQueryTest()
|
||||
{
|
||||
|
||||
$args = array(
|
||||
"post_status" => "publish",
|
||||
"post_type" => "artisans",
|
||||
"posts_per_page" => -1,
|
||||
// "tax_query" => $taxQuery,
|
||||
// "meta_query" => $metaQuery,
|
||||
's' => "Atelier Schrauwen",
|
||||
);
|
||||
$newsPostsDatas = new WP_Query($args);
|
||||
$filteredPosts = [];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
do_action('wpml_switch_language', 'nl');
|
||||
ob_start();
|
||||
get_template_part(
|
||||
'template-components/artisans/artisan-search-no-results',
|
||||
null,
|
||||
[]
|
||||
);
|
||||
$html_template = ob_get_clean();
|
||||
$test = __("Aucun résultat trouvé", "metiers-patrimoine-theme");
|
||||
return ($html_template);
|
||||
}
|
||||
// debugQueryTest();
|
||||
|
||||
// add_action('wp_footer', 'debugQueryTest');
|
||||
|
|
|
|||
|
|
@ -3,13 +3,3 @@
|
|||
@apply text-patrimoine-sante-securite;
|
||||
}
|
||||
}
|
||||
|
||||
.cta {
|
||||
@apply px-4 py-2;
|
||||
&--rounded {
|
||||
@apply rounded-full;
|
||||
}
|
||||
&--primary {
|
||||
@apply bg-patrimoine-sante-securite text-white;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@
|
|||
p {
|
||||
@apply text-neutral-900 tracking-wide;
|
||||
}
|
||||
#reset-all-artisans-button {
|
||||
@apply mt-4 mx-auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
.card-artisans {
|
||||
|
|
|
|||
|
|
@ -36,24 +36,6 @@ function observeSearchResetButton() {
|
|||
}
|
||||
});
|
||||
}
|
||||
function observeResetAllArtisansButton() {
|
||||
const resetAllArtisansButton = document.querySelector('#reset-all-artisans-button');
|
||||
resetAllArtisansButton.addEventListener('click', () => {
|
||||
resetSearchfield();
|
||||
hydrateWithAllArtisans({});
|
||||
});
|
||||
}
|
||||
function observeNoResultsApparition() {
|
||||
const grid = document.querySelector('.artisans-posts__grid');
|
||||
|
||||
const observer = new MutationObserver(() => {
|
||||
const noResults = grid.querySelector('.no-results');
|
||||
if (!noResults) return;
|
||||
|
||||
observeResetAllArtisansButton();
|
||||
});
|
||||
observer.observe(grid, { childList: true, subtree: true });
|
||||
}
|
||||
function clearAllCheckboxes() {
|
||||
const filtersCheckboxes = document.querySelectorAll('.taxonomy-checkbox');
|
||||
|
||||
|
|
@ -237,7 +219,7 @@ export default function dynamicSearch() {
|
|||
});
|
||||
|
||||
const searchForm = document.querySelector('.artisan-search-bar');
|
||||
|
||||
searchForm.addEventListener('submit', handleSearchSubmit);
|
||||
observeSearchResetButton();
|
||||
observeNoResultsApparition(); // Si la div no-results apparait, on observe le bouton reset all artisans pour gérer son comortement
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,4 @@
|
|||
<img class='no-results__cover' src="<?php echo get_stylesheet_directory_uri() . "/resources/img/illustrations/Homegrade_resultats-filtres-cactus.svg" ?>" alt='' />
|
||||
<h3><?php echo __("Aucun artisan correspondant actuellement", "metiers-patrimoine-theme") ?> </h3>
|
||||
<p> <?php echo __("Sélectionnez un ou plusieurs <span class='highlighted-purple'>métiers</span> ou <span class='highlighted-purple'>critères</span> pour lancer votre recherche", "metiers-patrimoine-theme") ?></p>
|
||||
<button class="cta cta--primary cta--rounded" id="reset-all-artisans-button">
|
||||
<?php echo __("Voir tous les artisans", "metiers-patrimoine-theme") ?>
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -22,7 +22,7 @@ $hasEmptyTaxos = (empty($elementsBatimentsTerms) && empty($metiersTerms)) ? 'car
|
|||
</div>
|
||||
<div class="taxonomy-tags card-taxonomies__taxonomy-tags">
|
||||
<?php foreach ($elementsBatimentsTerms as $key => $term) : ?>
|
||||
<span class="taxonomy-tag taxonomy-tag--<?php echo $term->parent === 0 ? 'parent' : 'child'; ?>"><?php echo $term->name; ?></span>
|
||||
<span class="taxonomy-tag"><?php echo $term->name; ?></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user