Hi,
i have a page with the search at the top and the view below it. When you search it filters the results.
What I want to do is have the search at the top and the view hidden and for only the filtered results to appear.
Is this possible?
Thanks!
Solved the problem using this code:
function show_hide_div() {
if (isset($_GET['lname'])) {
echo "jQuery('.with_frm_style.frm-responsive-table.Newtownbreda_View').show();";
} else {
echo "jQuery('.with_frm_style.frm-responsive-table.Newtownbreda_View').hide();";
}
}
add_action( 'wp_footer', 'show_hide_div' );
You put it in your funtions.php folder.
if (isset($_GET['lname'])) - You must replace "lname" with the paramenter that triggers the search
"jQuery('.view').show();"; - You must replace "view" with the class ID of your view.
That’s a nice alternative than doing it just in jQuery. Good job!
Please login or Register to submit your answer
I just had this issue.
I placed the search form on page A.
When someone searches, it redirects to page B/?parameter.
Page B has the search form and the view.
If Chris' issue is the one you're having as well, you could also do this on a single page with a little bit of jQuery to hide the view until there are any parameters in the URL related to the search. i.e., "if search parameters, show view, otherwise hide it"
Thank you for pointing us in the right direction Rob. I was able to solve this with the following code:
$( document ).ready(function() {
var currentURL = window.location.href; //grab the current window location
var targetDiv = $("#add_id_here"); //change this as per your code
targetDiv.hide(); //hide the div by defualt
if (window.location.href.indexOf('?parameter') != -1) { //add the parameter string
targetDiv.show(); //show the div if matched the current location
}
});
Hey Chris,
Thanks for sharing. I've no experience with jQuery.
Can you show me an example of the code with all the parameters filled out?
Thanks!
Hi Peter - what is the URL that your search form points to?