Tagged: search
- This topic has 3 replies, 3 voices, and was last updated 5 years, 4 months ago by
victorr.
-
AuthorPosts
-
October 19, 2016 at 11:29 pm #54975
Paul
MemberHi Eyal,
I am trying to figure out how to generate search results based on the URL of a page.
For example, a person visits a page mysite.com/barcelona/bags.
I want to display search results on this page that returns bags in barcelona.My question is: how can I pass GMW search function some arguments that it can return on the fly without using a search form? I want to load the dynamic results when the page loads.
Barcelona will be the location (obviously) and bags would be taken from a BP XProfile field.Can you suggest a function to use/manipulate?
October 23, 2016 at 3:20 pm #54991Paul
MemberBump.
Would really appreciate some input on this if you have time.
October 23, 2016 at 9:05 pm #54992Eyal Fitoussi
MemberHi,
This can be done, but there is no “simple” way to doit.You can create a form and use the “Page load results” tab to set the filters of the results that will be displayed when the page first loads. You can also disable the search form in the “Search form” tab.
Doing that you will have a form that will display list of results on page load.As for the filters of the address and xprofile fields, you will need to use some hooks and custom functions.
You will first need to pull the values of the address and xprofile field from the URL. Then, you can pass the address value to the form using the filter:
1apply_filters( 'gmw_main_shortcode_form_args', $form );which can be found in
geo-my-wp/includes/geo-my-wp-gmw-class.php
.
You need to filter the form array and pass the address to the “page_load_results” value of the array.For the xprofile fields part you can use the filter:
1apply_filters( 'gmw_fl_search_query_args', $args );which can be found in
geo-my-wp/plugins/friends/includes/gmw-fl-search-query-class.php
. Using this filter you can modify the arguments ( $this->form[‘query_args’] ) that passes to the bp_has_members() function which responsible for the members query.It does require PHP and WordPress hooks knowledge, but the above should be a start point.
I hope that helps.
February 24, 2017 at 1:04 am #55675victorr
MemberHi Eyal,
A lot of thanks for your plugin.
I´m trying to do what you recommend to create a form with dynamic cities depending on the user. In the web, in a previous form, user selects a city and it´s sended to database. So, i can create a variable to return the city selected by the user. The problem is that I don´t know exactly where I have to insert this variable in the “page_load_results”. I have tried adapting $this->form[‘org_address’] but i haven´t been able to get it.
Could you give me some input more about it.
Thanks,
Victor
-
AuthorPosts
You must be logged in to reply to this topic.