Compare commits
6 Commits
4fb24b1c01
...
8c26c27d19
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c26c27d19 | |||
| 93bf32774e | |||
| 2e930f0048 | |||
| d6ec861bf0 | |||
| 74eda13e56 | |||
| 1fabb25f97 |
25
blocks/page-redirector/block.json
Normal file
25
blocks/page-redirector/block.json
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"name": "acf/search-artisan-btn",
|
||||||
|
"title": "Redirecteur de page",
|
||||||
|
"category": "metiers-patrimoine-blocks",
|
||||||
|
"icon": {
|
||||||
|
"foreground": "#8B2FF7",
|
||||||
|
"src": "groups"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"artisan",
|
||||||
|
"bouton",
|
||||||
|
"rechercher",
|
||||||
|
"recherche"
|
||||||
|
],
|
||||||
|
"supports": {
|
||||||
|
"align": [
|
||||||
|
"full"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"acf": {
|
||||||
|
"mode": "auto",
|
||||||
|
"renderTemplate": "page-redirector.php"
|
||||||
|
},
|
||||||
|
"align": "full"
|
||||||
|
}
|
||||||
14
blocks/page-redirector/page-redirector.php
Normal file
14
blocks/page-redirector/page-redirector.php
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
// $dates_seminaire = get_field('dates_seminaire_datas');
|
||||||
|
|
||||||
|
$searchPageId = 43;
|
||||||
|
$searchPageTitle = get_the_title($searchPageId);
|
||||||
|
$searchPageUrl = get_post_permalink($searchPageId);
|
||||||
|
$searchPageIcon = get_field('page_icon', $searchPageId) ?? null;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<a class="search-artisan-btn" href="<?php echo $searchPageUrl ?>">
|
||||||
|
<img class="search-artisan-btn__page-icon" src="<?php echo $searchPageIcon['sizes']['medium_large'] ?> " alt="">
|
||||||
|
<?php echo __("Chercher une entreprise", "metiers-patrimoine-theme") ?>
|
||||||
|
</a>
|
||||||
|
|
@ -43,13 +43,14 @@ function build_search_artisan_posts_cards($request)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$metaQuery = [];
|
$metaQuery = [];
|
||||||
|
|
||||||
if ($localisation && $localisation !== 'all') {
|
if ($localisation && $localisation !== 'all') {
|
||||||
|
$localisationArray = explode(',', $localisation); // Séparer les localisations par des virgules
|
||||||
$metaQuery[] = array(
|
$metaQuery[] = array(
|
||||||
'key' => 'state',
|
'key' => 'state',
|
||||||
'value' => $localisation,
|
'value' => $localisationArray,
|
||||||
'compare' => '='
|
'compare' => 'IN', // Comparer avec plusieurs valeurs
|
||||||
);
|
);
|
||||||
// write_log($metaQuery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,8 @@ add_action('block_categories_all', 'metiers_patrimoine_add_block_categories', 25
|
||||||
function metiers_patrimoine_create_blocks_init()
|
function metiers_patrimoine_create_blocks_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// ACF
|
// ACF
|
||||||
// register_block_type(dirname(__DIR__) . '/blocks/btn-search-artisan');
|
|
||||||
register_block_type(dirname(__DIR__) . '/blocks/search-artisan-btn');
|
register_block_type(dirname(__DIR__) . '/blocks/search-artisan-btn');
|
||||||
|
register_block_type(dirname(__DIR__) . '/blocks/page-redirector');
|
||||||
}
|
}
|
||||||
add_action('init', 'metiers_patrimoine_create_blocks_init');
|
add_action('init', 'metiers_patrimoine_create_blocks_init');
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,17 @@
|
||||||
&__metiers-filters {
|
&__metiers-filters {
|
||||||
@apply border border-neutral-300 p-4 rounded-3xl my-4 w-full;
|
@apply border border-neutral-300 p-4 rounded-3xl my-4 w-full;
|
||||||
}
|
}
|
||||||
|
&__geographic-filters {
|
||||||
|
@apply hidden;
|
||||||
|
}
|
||||||
|
&:has(
|
||||||
|
#elements_batiments_checkbox:checked,
|
||||||
|
#metiers_checkbox:checked
|
||||||
|
) {
|
||||||
|
.metier-patrimoine-searchbar__geographic-filters {
|
||||||
|
@apply block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__elements-batiments-filters,
|
&__elements-batiments-filters,
|
||||||
&__metiers-filters {
|
&__metiers-filters {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ async function hydrateFields(formObjectDatas) {
|
||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleHierarchicalCheckboxRelation(e) {
|
function handleHierarchicalTaxonomyCheckboxRelation(e) {
|
||||||
// If parent is checked, check all children
|
// If parent is checked, check all children
|
||||||
if (
|
if (
|
||||||
e.target.checked &&
|
e.target.checked &&
|
||||||
|
|
@ -99,6 +99,30 @@ function handleHierarchicalCheckboxRelation(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleLocalisationCheckboxBehaviour(e) {
|
||||||
|
const AlllocalisationsCheckboxes = document.querySelector(
|
||||||
|
'.localisation-checkbox[value="all"]'
|
||||||
|
);
|
||||||
|
// If parent is checked, check all children
|
||||||
|
if (e.target.checked && e.target.value === 'all') {
|
||||||
|
const localisationCheckboxes =
|
||||||
|
document.querySelectorAll('.localisation-checkbox');
|
||||||
|
|
||||||
|
localisationCheckboxes.forEach((checkbox) => {
|
||||||
|
checkbox.checked = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!e.target.checked &&
|
||||||
|
AlllocalisationsCheckboxes.checked === true
|
||||||
|
) {
|
||||||
|
AlllocalisationsCheckboxes.checked = false;
|
||||||
|
}
|
||||||
|
if (e.target.checked && e.target.value !== 'all') {
|
||||||
|
AlllocalisationsCheckboxes.checked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleFormChange(e) {
|
function handleFormChange(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
@ -106,7 +130,13 @@ function handleFormChange(e) {
|
||||||
e.target.type === 'checkbox' &&
|
e.target.type === 'checkbox' &&
|
||||||
e.target.classList.contains('taxonomy-checkbox')
|
e.target.classList.contains('taxonomy-checkbox')
|
||||||
) {
|
) {
|
||||||
handleHierarchicalCheckboxRelation(e);
|
handleHierarchicalTaxonomyCheckboxRelation(e);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
e.target.type === 'checkbox' &&
|
||||||
|
e.target.classList.contains('localisation-checkbox')
|
||||||
|
) {
|
||||||
|
handleLocalisationCheckboxBehaviour(e);
|
||||||
}
|
}
|
||||||
const form = e.target.closest('form');
|
const form = e.target.closest('form');
|
||||||
const formData = new FormData(form);
|
const formData = new FormData(form);
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,11 @@ $adresse = get_field('adresse', $postID);
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($adresse): ?>
|
<?php if ($adresse): ?>
|
||||||
<p class="card-artisans__adresse"><?php echo $adresse['post_code'] . " " . $adresse['city'] ?></p>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
<p class="card-artisans__adresse">
|
||||||
|
<?= ($adresse['post_code'] ?? '') . ' ' . ($adresse['city'] ?? '') ?>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($phoneNumber): ?>
|
<?php if ($phoneNumber): ?>
|
||||||
<a class="card-artisans__phone" href="tel:<?php echo $phoneNumber ?>"><?php echo $formattedPhoneNumber ?></a>
|
<a class="card-artisans__phone" href="tel:<?php echo $phoneNumber ?>"><?php echo $formattedPhoneNumber ?></a>
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,6 @@ $pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
|
||||||
</ul>
|
</ul>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
||||||
<fieldset class="metier-patrimoine-searchbar__geographic-filters">
|
<fieldset class="metier-patrimoine-searchbar__geographic-filters">
|
||||||
|
|
||||||
<div class="fieldset-titling">
|
<div class="fieldset-titling">
|
||||||
|
|
@ -164,27 +163,23 @@ $pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li class="checkbox-choice">
|
<li class="checkbox-choice">
|
||||||
<input type="checkbox" name="localisation[]" value="all">
|
<input class="localisation-checkbox" type="checkbox" name="localisation[]" value="all" checked>
|
||||||
<label> <?php echo __("Toute la Belgique", "metiers-patrimoine-theme") ?></label>
|
<label> <?php echo __("Toute la Belgique", "metiers-patrimoine-theme") ?></label>
|
||||||
</li>
|
</li>
|
||||||
<li class="checkbox-choice">
|
<li class="checkbox-choice">
|
||||||
<input type="checkbox" name="localisation[]" value="wallonia">
|
<input class="localisation-checkbox" type="checkbox" name="localisation[]" value="wallonia" checked>
|
||||||
<label> <?php echo __("Wallonie", "metiers-patrimoine-theme") ?></label>
|
<label><?php echo __("Wallonie", "metiers-patrimoine-theme") ?></label>
|
||||||
</li>
|
</li>
|
||||||
<li class="checkbox-choice">
|
<li class="checkbox-choice">
|
||||||
<input type="checkbox" name="localisation[]" value="brussels" checked>
|
<input class="localisation-checkbox" type="checkbox" name="localisation[]" value="brussels" checked>
|
||||||
<label> <?php echo __("Bruxelles", "metiers-patrimoine-theme") ?></label>
|
<label> <?php echo __("Bruxelles", "metiers-patrimoine-theme") ?></label>
|
||||||
</li>
|
</li>
|
||||||
<li class="checkbox-choice">
|
<li class="checkbox-choice">
|
||||||
<input type="checkbox" name="localisation[]" value="flanders">
|
<input class="localisation-checkbox" type="checkbox" name="localisation[]" value="flanders" checked>
|
||||||
<label> <?php echo __("Flandre", "metiers-patrimoine-theme") ?></label>
|
<label> <?php echo __("Flandre", "metiers-patrimoine-theme") ?></label>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|
||||||
<!-- <button type="submit">submit</button> -->
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user