Forums › Forums › Search & Filter Pro › Search in category page without leaving the page
- This topic has 10 replies, 2 voices, and was last updated 7 years, 10 months ago by
Trevor.
-
Anonymous(Private) May 7, 2017 at 5:00 am #106973
Hello,
I would like to have a search form in the category page, then when searching not leave this page, just filter and keep the category information, is that possible?
I’ve tried using the “shortcode” method inserting the the search shortcode and results shortcode in the category.php, but it says I must insert a full URL for the results shortcode and won’t work. I’ve used an old version of search and pro before and it worked this way using shortcode, searching without leaving the page.
Thanks,
Rafael
Anonymous(Private) May 7, 2017 at 5:26 am #106975UPDATE: I had checked the option “Only use Ajax on the results page?”, I unchecked it and now its loading without leaving the category page, but on admin page I still get the alert “Error: Your Results URL is empty – go to Display Results tab to fix”, even though it is working.
Will I have any problem using it the way I configured it?
Trevor(Private) May 8, 2017 at 2:09 pm #107222I will answer the first post. If you have Ajax ON and set it to As an Archive, the template file choice is key, but that is down to the theme and you knowing which template the category page uses.
You will also need to make sure that Category is added to the form, even if you don’t want to use it (in which case use Custom CSS to hide it), so that (as you should have set) if you have auto detect Category set to ON (in the General Settings tab), the field will be filled in.
Anonymous(Private) May 8, 2017 at 3:57 pm #107288Hello Trevor,
Thanks for the answer!
When I use as an archive, even if I have ajax on it redirects the URL, but I don’t want to leave the category.php page, so if I’m on the category URL http://localhost/escolasja/brasil/parana/ (I know it’s local, just want to show the URL) I load the category name, category banner (ACF field), etc, and after the first filter, it leaves the category.php (as an archive) and I lose the category title, banner etc.
To solve this problem, I have set it as a shortcode, so on my category.php template file I have both <?php echo do_shortcode( ‘[searchandfilter id=”34″]’ ); ?> and <?php echo do_shortcode( ‘[searchandfilter id=”34″ show=”results”]’ ); ?>. Before it wasn’t working because I had checked “Only use Ajax on the results page?”, but after unchecking it is working as I want, so the problem is solved, but I still get the alert “Error: Your Results URL is empty – go to Display Results tab to fix”, and I’m wondering if I will have a problem for leaving that empty? If I fill with the URL of the results page I’ll lose the category info as well.
Like I said, my problem is solved now, just wondering if what I did is wrong or not, if its ok to configure the way I did you can close the ticket, thank you very much!
Rafael
Anonymous(Private) May 8, 2017 at 6:37 pm #107395Hi Trevor,
Oh so I found how to stay on the category page by accident then, but I think I just found out a problem of that, I didn’t see before but the pagination doesn’t work in this method, if I click on next page link it won’t load a new page, and if I manually type /page/2 on browser it does find a page instead of error 404 but the result is still from page 1. The filtering works fine and very well, but not pagination. Is that problem I’m having because of how I configured it or is there any way to change the query on results.php to make pagination work?
If pagination won’t work because I’m using a shortcode without a URL, is there any other way to retrieve information about the category in my filter if I use as an archive? It’s very important for the client to keep information of the category selected in the page.
UPDATE: while I was writing this problem, something came to my mind and I tested, so in my functions I use a function to translate the URLs, so “page” is translated to “pagina” (Brazilian portuguese). After removing this function the pagination worked using the shortcode method without leaving the page, but now the URL is ?sf_paged=2 instead of “page/2” or “pagina/2” like I wanted. Is there any way to translate/change that URL?
The function I was using:
// TRADUZIR URLS
function re_rewrite_rules() {
global $wp_rewrite;
$wp_rewrite->author_base = ‘autor’;
$wp_rewrite->search_base = ‘buscar’;
$wp_rewrite->comments_base = ‘comentarios’;
$wp_rewrite->pagination_base = ‘pagina’;
$wp_rewrite->flush_rules();
}
add_action(‘init’, ‘re_rewrite_rules’, 10);I decided to keep the main problem before the UPDATE just so you can have more information.
Thanks again Trevor, really appreciate.
Trevor(Private) May 8, 2017 at 7:28 pm #107434The base problem is that you are trying to do something (stay on a category page) that our plugin was never designed (nor advertised) to do, and so all that follows is a workaround and will become ever more complex.
As I said, I think V3 (the version we are currently working on) will allow you to do what you want.
If you can get it working with some compromise, I would stay with that until V3 is released (it will be some months yet).
Anonymous(Private) May 8, 2017 at 7:47 pm #107454Hello Trevor,
Ok I will do that, won’t hurt to have paginations URL in english, just wanted to optimize, but as of now the main purpose of what my client needs is working.
Two more questions though:
Question 1 – I want to try to use infinite scroll for pagination, if it doesn’t work no problem though, but the inifite scroll documentation page says the following:
“Tutorial
I will be writing a quick tutorial for the Archive (using WP 2016 theme) and Shortcode display methods over the next couple of weeks.”Is there any tutorial for me to follow to use infinite scroll on shortcode method? I tried with the default and didn’t work, if theres nothing for now I’ll just use the way it’s working now and wait for V3.
Question 2 – I looked on documentation and on forums but I didn’t find the answer or didn’t search with the right terms, but is is possible to show somewhere in the page which filters were selected and the option to remove them?
Thank you very much for the attention Trevor,
Rafael
Trevor(Private) May 8, 2017 at 9:37 pm #107491Q1. I am not sure you need to do anything special. The shortcode method now comes with two results templates, one of which is for the infinite scroll, and the plugin should use that one when you select that option.
Q2. Yes. See these two threads for some guidance:
https://support.searchandfilter.com/forums/topic/accessing-the-search-data/
https://support.searchandfilter.com/forums/topic/showing-the-search-query/
They also link to the documentation that relates to this functionality.
Anonymous(Private) May 9, 2017 at 2:14 am #107522Hello Trevor,
About the infinite scroll, not yet working but it’s not that important right now, so I will go back to it another day.
About the search query, with your links I managed to get the name of the checked filters, but I couldn’t find how to remove from the query by clicking those filters, is there any link on that?
I used the solution you gave here:
https://support.searchandfilter.com/forums/topic/results-displayed-results-count-searched-tag-associated-categories/Most of my filters are checkboxes and one is a dropdown, thats why that solution was best for me because of the “foreach” to show more than one checked, so based on that how could I add a div/script to the selected filter and then remove on click?
Thanks again.
-
AuthorPosts