链接到实际搜索页面的搜索表单

发布于 2024-09-11 16:05:46 字数 292 浏览 4 评论 0 原文

我使用公开的过滤器和视图模块创建了一个搜索页面。用户可以选择不同的值以获得具有特定结果(返回节点字段)的表。此页面位于 mysite.com/search 下。问题是我想在我的主页上放置一个简化版本的搜索表单(假设只是关键字搜索框+一两个复选框)。这可以是块或视图。当用户按下搜索按钮时,我想将他重定向到搜索页面并显示结果。在这里,用户应该能够以普通方式细化他的搜索。我想这可以通过 HTTP GET 参数并指向实际的搜索站点来实现。然而,我想知道是否可以在不对主页上的表单进行硬编码的情况下(即通过使用视图、块等)来做到这一点。我希望这是有道理的。任何帮助将不胜感激。

I have created a search page uising exposed filters and views module. The user can choose from different values in order to get a table with specific results (returning node fields). This page is located under mysite.com/search. The problem is that I would like to put a simplified version of the search form on my homepage (lets say just the keyword search box + one or two checkboxes). This can be a block or a view. When the user presses the search button I would like to redirect him to the search page and show the results. Here the user shall be able to refine his search in an ordinary way. I guess this can be achieved by HTTP GET parameters and pointing to the actual search site. I was wondering however if I could do it without hardcoding the forms on my homepage, i.e. by using views, blocks, etc. I hope this makes sense. Any help will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦归所梦 2024-09-18 16:05:47

编辑

最终结果是您希望使用一个表单将您带到搜索结果页面,并在搜索结果页面本身上使用另一个高级表单。该解决方案通过为每个表单创建两个具有不同过滤器的相同视图来实现此目的。

当有人使用简化表单时,他们会被带到 example.com/search,而当他们在该页面上并使用高级表单时,他们会被带到 example.com/search/advanced。由于视图与相似路径相同,因此最终用户不会知道其中的差异。

实现此目的的方法如下:

  1. 创建搜索结果的视图。使用默认显示来设置您想要的搜索结果。对于过滤器,仅放入自动过滤器:不要放入您希望用户能够过滤的内容。
  2. 在该视图中创建一个新页面显示。给它一个搜索路径。这将是用户在使用简化的搜索表单时点击的结果页面。
  3. 在此页面显示中,覆盖过滤器。设置并公开您想要的简化搜索表单的过滤器。
  4. 覆盖此显示的基本设置中的在块中公开表单并将其设置为
  5. 在视图中创建一个新页面显示,并为其指定路径搜索/高级。这将是用户使用高级搜索表单时点击的结果页面。
  6. 覆盖此显示的过滤器,设置并公开高级搜索表单所需的过滤器。
  7. 覆盖此显示的基本设置中的在块中公开表单并将其设置为

现在,您将拥有两个视图页面:搜索搜索/高级,以及两个块:一个简化的搜索表单和一个高级搜索表单。

转到块管理,然后启用简化搜索块。使用路径特定的可见性设置来设置您希望简化搜索框出现的位置。

现在,启用高级搜索块。使用路径特定的可见性设置将可见性设置为:

search
search/*

假设您想使用一组不同的过滤器创建另一个简化的搜索块(我们称之为替代)。您也可以这样做:按照步骤 2-4 中的操作在视图中创建另一个页面显示,但不要使用路径 search,而是为其提供不同的路径:search/alternate嗯>。您可以根据需要添加任意数量的具有不同过滤器的简化表单,并且当您使用它们时,它们都将具有高级搜索表单和相同的结果。

Edit

The end result is that you want to have one form bring you to the search results page, and another advanced form on the search results page itself. This solution accomplishes this by creating two identical views with different filters for each form.

When someone uses the simplified form, they're taken to example.com/search, and when they're on that page and use the advanced form, they're taken to example.com/search/advanced. Because the views are identical with similar paths, the end user won't know the difference.

Here's how to accomplish this:

  1. Create a view for the search results. Use the default display to set up the search results however you want. For filters, only put in automatic filters: don't put in the stuff you want the user to be able to filter by.
  2. Create a new page display in that view. Give it a path of search. This is going to be the results page that a user hits when they use your simplified search form.
  3. In this page display, override the filters. Set up and expose the filters you want for the simplified search form.
  4. Override Expose form in block in the Basic settings for this display and set it to yes.
  5. Create a new page display in the view, and give it a path of search/advanced. This is going to be the results page that a user hits when they use the advanced search form.
  6. Override the filters for this display, set up and expose the filters you want for the advanced search form.
  7. Override Expose form in block in the Basic settings for this display and set it to yes.

Now, you'll have two view pages, search and search/advanced, and two blocks, a simplified search form and an advanced search form.

Go to the block administration, and enable the simplified search block. Use the path specific visibility settings to set where you want the simplified search box to appear.

Now, enable the advanced search block. Use the path specific visibility settings to set the visibility to:

search
search/*

Let's say you wanted to create another simplified search block with a different set of filters (let's call this alternate). You can do that too: create another page display in your view as you did in steps 2-4 but instead of using the path search, give it a different path: search/alternate. You can add as many simplified forms with different filters as you want, and they'll all have the advanced search form and the same results when you use them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文