Is it possible to display the titles of search options above a table of results?
For Example:
Search and filter options were:
Locations
Location 1
Location 2
Location 3
Buildings
Building 1
Building 2
Building 3
If the user selected Location 2 and Building 3
Is there a way to display those 2 as a title above the table of results?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
Thank you for contacting our support forum.
What do you mean the titles of search ? Are you referring to what the user had searched for ?
Please let me know.
Thanks,
Shane
Yes what the user has searched for.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila
The only way to do this is by having the text search bar on your parametric searches.
It's not possible to have a dropdown search bar for this.
Thanks
Shane
For example see attached.
User has selected the date 27/07/2019 and Building: Laurus
Is it possible to have these 2 displayed above the table of results (see red circled area)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
Yes this is possible and you can do it with this shortcode here.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term
Please let me know if this helps.
Thanks,
Shane
Thanks that worked, but the date is displaying raw numbers (see attached)
I added a date format but that didn't work.
<h3>[wpv-search-term param="wpv-wpcf-target-date" format="Y-m-d"]
[wpv-search-term param="wpv-wpcf-building-access-required"]</h3>
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
So for the date field it gives a timestamp, the format="Y-m-d" attribute won't work here as its not a valid attribute of this shortcode.
I've created a custom shortcode to help you format this.
// Add Shortcode
function wp_convert_timestamp( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'timestamp' => '',
'format' => '',
),
$atts
);
$date = date($atts['format'], $atts['timestamp']);
return $date;
}
add_shortcode( 'wp_convert_timestamp', 'wp_convert_timestamp' );
Add this to your toolset custom shortcode in Toolset -> Settings -> Custom Code and ensure that its activated.
The usage in your case would be.
[wp_convert_timestamp timestamp="[wpv-search-term param='wpv-wpcf-target-date']" format="Y-m-d"]
Thanks,
Shane
Hey! I followed the instructions, but it's displaying the shortcode and the date, have I missed something?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
Did you click the activation button on the custom code when you added it to the toolset custom code section ?
Opps no it wasn't active, but now it's showing
Warning: date() expects parameter 2 to be integer, string given in /nas/content/live/biocityhq/wp-content/toolset-customizations/wp_convert_timestamp.php on line 22
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
So i suspect that happens when there isn't any parameter.
Try it like this.
// Add Shortcode
function wp_convert_timestamp( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'timestamp' => '',
'format' => '',
),
$atts
);
$date="";
if(!empty($atts['timestamp'])){
$date = date($atts['format'], $atts['timestamp']);
}
return $date;
}
add_shortcode( 'wp_convert_timestamp', 'wp_convert_timestamp' );
This should fix your issue now.
Thanks,
Shane
Add the code, still the same.
Do I need to update the code in views or does that still remain as
[wp_convert_timestamp timestamp="[wpv-search-term param='wpv-wpcf-target-date']" format="Y-m-d"]
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
You shouldn't need to make any changes on the frontend.
Would you mind allowing me to have admin access to the site so that I can have a look at what is happening here for you ?
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Leila,
The code should be working now.
The problem was that it was not copied correctly and had a bunch of special characters in it.
Thanks,
Shane