Search field - pre populate automatically with user location - drupal

I've seen some website, once you on the front page, it automatically populate the search field with your location. I want to implement the same thing for my directory site. One field, is for whatever they want to search for, and the second field is a location field for the user to enter the city or postcode they want to search on.
I want to pre-populate the location field, automatically once the user landed on front page. Any modules that I can use for this?

It will depend on which search engine/backend you use. Using Solr, you can use the Geolocation Field module in conjunction with Search API Location.
The Search API Location module adds the possibility of location based searching to the Search API module (currently only Apache Solr is supported as the service class).
Geolocation Field provides a field type to store geographical locations as pairs of latitude and longitude (lan,lng) as well as the necessary integration to display those locations through views, fields and using a number of different map providers.
Once configured, you will be able to pre-populate the location field by hooking into your search form using hook_form_alter.

Related

How to configure ElasticPress WordPress plugin to leverage exsting Elasticsearch index for autocomplete searchbox

Facts:
Using existing Wordpress 4.8 implementation Added Elasticpress plugin
Have existing Elasticsearch 5.4 environment
Loaded 1,000 JSON documents from file, and successfully created an
index
Relevant fields in index: carName, carURI
Looking to create simple webpage in order to implement an autocomplete scenario, whereby user would begin searching for item by name (a car, let's say), searching against (carName) in the index, and gets a limited number of matching results for carName, with URI link to relevant webpage (carURI).
Upon reading documentation for ElasticPress, it appears primarily to index a Wordpress site, and commit it to ES as an index, and use it to search captured site data. Can it be leveraged as a search target from an existing index in ES?

Linking User Type To Data In Google Analytics

I'm working with linking a user type to a particular field in google analytics. For example, if I want to know the top search words from the user type "Customers", I'm creating a custom report in GA and adding in the fields like search word along with the custom dimension (user-type). But the search word is not being linked to a particular user type.
Is there any way of knowing that a search word came in from this user type ? Does google do that internally or do we have to some how link which search words came from which user types?
If the User type is a dimension in the reports, you can use a new segment in the Overview of Site Search and use a Condition that includes in the report only the type "Costumers".
The report with this filter will only show data, as search term, from these specific type of user.
Hope I've helpd.

Drupal 7 and Views, contextual filters searching through multiple/combined fields. Is it possible?

I've worked with Drupal 7 and Views for a while now and I'm familiar with what Views allow by default and what is available as modular add-ons. Today I've come across an issue with Contextual filters, which allow you to pass in an argument via the URL and use this to filter the returned data.
Normal filters on the other hand can be exposed as a form and also allow for a field combination module which means we can search field{1,2,3} all at once and display the data depending on this input. (views_combined_fields)
Is it possible to tell Views to show me all rows (WHERE field1="test" OR WHERE field2="test" OR WHERE field3="test") but by default, if I add in multiple contextual filters only one of them is being triggered. In this example the "test" value is obtained from the url /data/test.
My problem is that users have a default group, but they also have the option to be added into other groups which are set in the field{1,2,3} fields. My current view shows all users WHERE group = "test" but I want users who have a secondary or tertiary group of "test" to also be displayed in this list.
As i understood, you are talking about Views Arguments, watch the tutorial video from
MustardSeedMedia.com. And useful video about Views 3 User Interface

Expose filter multiple search in drupal

I have one Drupal website where there is a list of all temples, mosques, church etc available. Now i want a search form in my front page where user can search temples, mosques, church etc. I am using View exposed filter for searching results. But problem is when i go to add filter criteria then It ask for specific CCK field to exposed.
In Drupal machine name is always unique. So for temples it takes different machine name and for mosques it takes different.
I want only one search form where user can search all temples, mosques etc. Right now i am using different search form for different one. How can i do this with only one search form???
One more thing I am using these modules for handling addresses and locations
Address Field - 7.x-1.0-beta3
Geofield - 7.x-1.1
GeoPHP - 7.x-1.6
Geocoder - 7.x-1.2
How can i search results based on city and locations?
Assuming that you want to make the searches by name, then you should use the same field for all the temples' names, regardless of their type. By doing that exposing that field will do what you want.

Drupal: map address geolocation search

I am using the gmap and location modules to display a map. I would like the users to be able to fill an address in a field and the map autocenters and autozooms to that address. Like maps.google.com does it.
Is there a module or any specific configuration I can do with drupal? Ultimately I would like to create an advance filter where user inputs country, province and address and posibly select from a drop down list. Something very similar to what it is done in the following link http://www.dei.gr/Default.aspx?id=30608&nt=18&lang=2&langid=1
Thanks.
The GMap Location Module is the one which fits the requirements most closely.
"Provides a map of all a site's nodes and a map of all of the site users."
If you'd like to create it by yourself:
Would suggest to create 2 tables - with labels and center-points - in order to populate these cascaded drop-downs.
The last input-box needs to geo-code the entered text - over the Google GeoCoder API.
Of course any centerpoint could be geo-coded - but you have a limit of 2.500 API requests per 24hrs on the PHP API,
unless being a premier customer (besides local results are just quicker). That's why it's recommend to store the center-points for each item in the drop-downs in a table - and only use the JS API (instead of the PHP API) for the last step.
The example which you provided reloads the whole page when changing the drop-downs, which should be avoided.

Resources