Hello, This is a very specific question and probably requires a code snippet. However, I’m unable to modify the URL and change its format.
For example, natively in Bricks, I have this: ?_date=2025-04-23%2C2025-04-25
What I want is to modify the URL using a code snippet to get this:
?_date=checkin_checkout!date:2025.4.23-2025.4.25
// FILE: bricks-date-to-jetsmart.php
add_action('bricks/filters/init', 'integrate_jetsmart_date_filter');
function integrate_jetsmart_date_filter() {
// 1. Register custom filter type (if needed)
if (function_exists('bricks_register_filter')) {
bricks_register_filter([
'name' => 'jetsmart_date',
'label' => 'JetSmart Date',
'apply' => 'apply_jetsmart_date_filter',
]);
}
// 2. Hook into Bricks' query system
add_filter('bricks/query/run', 'modify_bricks_date_query', 10, 2);
}
function modify_bricks_date_query($query_args, $settings) {
// Only process on the correct page template
if (!is_page('property')) {
return $query_args;
}
// Check for Bricks date parameter
if (isset($_GET['_date']) && !empty($_GET['_date'])) {
$date_value = sanitize_text_field($_GET['_date']);
// Skip if already in correct format
if (strpos($date_value, 'checkin_checkout!date:') !== false) {
return $query_args;
}
// Convert date format
$converted_date = preg_replace_callback(
'/(\d{4})-(\d{2})-(\d{2})[,%2C](\d{4})-(\d{2})-(\d{2})/',
function($matches) {
return sprintf('checkin_checkout!date:%d.%d.%d-%d.%d.%d',
$matches[1], (int)$matches[2], (int)$matches[3],
$matches[4], (int)$matches[5], (int)$matches[6]
);
},
urldecode($date_value)
);
// Update query parameters
$query_args['meta_query'] = [
[
'key' => 'property_dates', // Match your custom field
'value' => $converted_date,
'compare' => 'LIKE'
]
];
// Update URL parameter silently
add_action('bricks/filters/after', function() use ($converted_date) {
?>
<script>
document.addEventListener('bricks/ajax/filters/init', function() {
const url = new URL(window.location.href);
if (url.searchParams.get('_date') !== <?php echo json_encode($converted_date); ?>) {
url.searchParams.set('_date', <?php echo json_encode($converted_date); ?>);
history.replaceState({}, '', url.toString());
}
});
</script>
<?php
});
}
return $query_args;
}
As you can see, I’ve already tried several combinations, but I can’t get it to work. Something is probably missing… perhaps a specific hook that I am unaware of.
Unfortunately, the Bricks documentation doesn’t mention a way to modify the behavior of the “Filter - Datepicker.”
If anyone understands what’s missing or has a solution, thank you for sharing.
And if a developer happens to pass by and understands what’s going on, thank you as well for sharing a solution!
EDIT :
on the left jetsmartfilters on the right bricks filter
While the code clearly illustrates what I’m trying to achieve, I’d like to provide some additional context about the reasoning behind it. Datepicker could be far more flexible and adaptable to various external solutions if it offered parameters directly within Bricks, either as options or through new hooks.
My objective is to move away from Jetsmartfilters since the only element linking me to it is the date range used to locate the checkin_checkout properties (Jetbooking). Datepicker Bricks could handle this task perfectly if it were able to conform to the specific URL pattern required by Jetbooking.