搜索字段 – 自动预填用户位置

huangapple go评论65阅读模式
英文:

Search field - pre populate automatically with user location

问题

我看过一些网站,一旦你进入首页,它会自动将搜索字段填充为你的位置。我想为我的目录网站实现类似的功能。一个字段是用于输入他们想搜索的内容,第二个字段是一个位置字段,用户可以输入他们想要搜索的城市或邮政编码。

我想在用户登陆首页时自动填充位置字段。有没有可以用于这个功能的模块?

英文:

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?

答案1

得分: 1

这将取决于您使用的搜索引擎/后端。使用Solr,您可以与地理位置字段模块一起使用Search API Location

Search API Location模块为Search API模块添加了基于位置的搜索功能(目前仅支持将Apache Solr作为服务类)。

Geolocation Field提供了一种字段类型,用于将地理位置存储为纬度和经度(lat,lng)对,以及通过视图、字段和多种不同地图提供商显示这些位置的必要集成。

一旦配置完成,您将能够通过使用hook_form_alter来钩入您的搜索表单,预填充位置字段。

英文:

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.

huangapple
  • 本文由 发表于 2020年1月3日 22:17:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580122.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定