我在 Drupal 6 中使用 CCK,我需要在 Drupal 中构建一个搜索表单,其中 8-10 个字段用作过滤器。当用户提交表单时,我需要在数据库上进行查询,应用过滤器并将结果显示在表格上。
我知道如何通过动态构建 SQL-where 条件(连接节点和 content_type_xyz 表)以编程方式执行此操作,但我有兴趣学习如何以“Drupal 方式”执行此操作。我想我必须使用视图和面板,但我不知道它们是否可以在这种情况下轻松实现。我尝试构建一些示例视图,但我认为手动创建代码会更快。
问问题
1059 次
2 回答
1
If you want custom searches you need IMO to do 2 things:
- Hook yourself into _search so you can use Drupal's display for the results. Inside this form, you can create your queries for the database or load other content as you wish, just be sure to use pager_query.
- Extend the search form that already exists or built your own. I suggest buliding your own. use what is already existing from Drupals search form. This way, you have a clean way of how to do this.
There is actually no need to use any fancy modules (that doesn't mean you should rule them out, but a search is something so esential that it is quite well handled with the basics).
Using the above, you'll get a native search form with all it's power and can make use of global paging options.
于 2011-01-27T19:16:31.467 回答
0
如果您使用视图执行此操作,您将仅限于可以使用 SQL 执行的过滤。Views 是一个 SQL 构建器,不包含任何“适当的”搜索功能。也就是说,听起来 Views 会做你想做的事;如果您在视图下创建过滤器,然后单击“公开此过滤器”,您会突然看到允许用户输入要过滤的内容的字段出现。
于 2011-01-28T16:11:38.977 回答