Home › Toolset Professional Support › [Resolved] One search form for two different views
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Tagged: Custom search, Views plugin
Related documentation:
This topic contains 32 replies, has 2 voices.
Last updated by Franck 4 years, 9 months ago.
Assisted by: Minesh.
Hello Franck,
Sorry, but I did not yet touch the site since the last Friday and in order to remove such collisions, we always recommend to share a staging site copy or duplicator copy of your site as debug on the live site is not recommended. Also, Please always take the backup of your site so if in case it broken you will have a copy to restore.
Once you give me a green signal to work on a test page you shared: hidden link
- I will work after I get your permission.
Also, I will duplicate your view's so that your existing pages that contains that view will not have any effect.
I didn’t change any thing neither 🙁
It is strange the search is hidden 🙁
hidden link
I have to
Create ticket ?
So, I checked the test page you created for me:
=> hidden link
I removed everything from the page and just added the "hi there" text message as you can see with the above link but still when I see the "Test Toolset" page on frontend - I can still see the listing.
=> hidden link
There must be some caching from a server or I'm not sure from where the results coming from as now the test page you shared is having the "hi there" text. are you using any server-side caching? If yes, can you please disable that.
In addition to that, I see you are using an outdated WordPress version. Please update WordPress to latest version. Do not forget to take the backup before you run any update.
It looks like really there is caching issue as with the test page you shared: hidden link
Now, after I update the page and views and after some time I can see the page with filters on my test page:
=> hidden link
And I can see now on the page you requested with filters:
=> hidden link
Is there any other people working on the site as well as, as I suspected there is caching issue so the changes you made does not reflect.
Also, I found that the checkbox "Disable the wrapping DIV around the View " was checked, I unchecked it as to run a custom search you must uncheck that checkbox with the following view:
=> hidden link
Someone must have changed that checkbox as it was not checked before.
Hi,
Right know i have fixe problem i think with cache. I think you can use test page.
The checkbox is unchecked, thanks.
Hi MInesh, i am not sure where we are with this problem ? Do you work on it or you wait something from me ?
I can still experience the cache issu - whatever changes I made to view does not take effect on frontend.
For example - the following view is a duplicate copy of your original view where I'm working on. With the following view, I've added the two buttons in the search form:
=> hidden link
[wpv-filter-submit name="Search Child" output="bootstrap"] [wpv-filter-submit name="Search Parent" output="bootstrap"]
But on the frontend, I see the old view and do not see any changes.
=> hidden link
Can you please disable the cache for now.
Could you make the lien start from "conseillers"
in this case cache won't work.
Sorry - I do not get what you are saying. Can you please be more specific or share screenshot.
it is ok i have done it.
Sorry - what you have done?
I can not see the buttons I've added yet on the test page: hidden link
The page is hidden link
I see the button
Thanks - you changed the slug of the test page. I can see now the buttons.
So, as you can see, there are two buttons "Search Child" and "Search Parent":
=> hidden link
This is the view that is been used with the above page:
=> hidden link
As you can see with the "Loop Editor" section, I've added the [wpv-conditional] shortcode to check what button is currently clicked and based on that it will display the results. This is how the loop editor content looks like;
<div class="panel panel-default"> <div class="panel-body mt-20"> [wpv-layout-start] [wpv-items-found] [wpv-conditional if="( '[wpv-search-term param='wpv_filter_submit']' eq 'Search Child' )"] <p class="mt-20 mb-20 gros-p">Affichage de [wpv-items-count] lot(s) sur [wpv-found-count] trouvé(s).</p> <table class="table display dataTable table-striped table-responsive" style="width:100%"> <!--<table class="backgound-3-a mt-20 table table-striped table-bordered table-responsive" style="width:100%">--> <thead> <tr> <th>Code postal</th> <th>Ville</th> <th>Dispositif</th> <th>Promoteur</th> <th>[wpv-heading name="types-field-nom-du-programme"]Nom du programme[/wpv-heading]</th> <th>[wpv-heading name="types-field-typologie-du-lot"]Typologie[/wpv-heading]</th> <th>[wpv-heading name="types-field-surface-habitable"]Surface[/wpv-heading]</th> <th>[wpv-heading name="types-field-prix-ttc"]Prix TTC[/wpv-heading]</th> <th>[wpv-heading name="types-field-date-de-livraison"]Date de livraison[/wpv-heading]</th> </tr> </thead> <!-- wpv-loop-start --> <tbody class="wpv-loop js-wpv-loop"> [/wpv-conditional] <wpv-loop> [wpv-conditional if="( '[wpv-search-term param='wpv_filter_submit']' eq 'Search Child' )"] <tr> <td>[types field='code-postal'][/types]</td> <td>[types field='ville'][/types]</td> <td class="text-nowrap">[wpv-post-taxonomy type="dispositif" format="name" separator="<br />"]</td> <td class="text-nowrap">[types field='nom-du-promoteur' item='@programme-lot.parent'][/types]</td> <td class="text-nowrap"><a target="_blank" href="/conseillers-programme/?id_programme=[wpv-post-id item="@programme-lot.parent"]#[wpv-post-id]">[types field='nom-du-programme'][/types]</a></td> <td class="text-nowrap">[types field='typologie-du-lot'][/types]</td> <td class="text-nowrap">[types field='surface-habitable'][/types] m2</td> <td class="text-nowrap">[number-format][types field='prix-ttc'][/types][/number-format]€</td> <td class="text-nowrap">[types field='date-de-livraison' style='text' format='j F Y'][/types]</td> </tr> [/wpv-conditional] [wpv-conditional if="( '[wpv-search-term param='wpv_filter_submit']' eq 'Search Parent' )"] [wpv-post-body view_template="conseillers-recherches-programmes-blog-programme"] [/wpv-conditional] </wpv-loop> <!-- wpv-loop-end --> </tbody> </table> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]Aucun lot trouvé[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end] <div class="text-center"> <ul class="pagination"> <li class="page-item">[wpv-pager-nav-links output="bootstrap" previous_next_links="true" step="1000" reach="2"]</li> </ul> </div> </div> </div>
You can adjust the content within both the conditional statements as required.
Thanks for answer, but it is not what i want, because in this case, you use the same view. And you display just child not parent.
In this view, i display the parent and not the child hidden link
I've adjusted the code to search for the parent as given under - where I've changed the If condition for view ID 85961 and the code will be applied when view ID 85961 will be in question and you submit the form suing the "Search Parent" button.
add_filter( 'wpv_filter_query_post_process', 'func_group_by_parent_post', 10, 3 ); function func_group_by_parent_post( $query, $view_settings, $view_id ) { if ($view_id == 84926 or ($view_id == 85961 and $_GET['wpv_filter_submit']=="Search Parent") ) { /* echo "<pre>"; print_r($query); print_r($query->posts); foreach($query->posts as $k=>$v): $parent = toolset_get_related_post( $v->ID,'programme-lot' ); $all_post_ids[]= $parent; endforeach; print_r($all_post_ids); $x = array_unique($all_post_ids); print_r($x); exit; */ $all_post_ids = array(); $all_found_posts = $query->posts; foreach($all_found_posts as $k=>$v): $parent = toolset_get_related_post( $v->ID,'programme-lot' ); $all_post_ids[$parent]= $v; endforeach; $query->posts = $all_post_ids; } return $query; }
I see with the following link 3 search filters applied:
hidden link
Now, when I click on the search button "Search Parent" having the same filters applied, I can see the same results as you can see with the following link:
hidden link
And when you click on the button "Search Child", it will give you another view.