Drupal 6 中的自定义搜索表单:视图/面板还是自定义 sql?
我在 Drupal 6 中使用 CCK,并且需要在 Drupal 中构建一个搜索表单,其中包含 8-10 个字段用作过滤器。当用户提交表单时,我需要对应用过滤器的数据库进行查询并将结果显示在表上。
我知道如何通过动态构建 SQL-where 条件(连接节点和 content_type_xyz 表)以编程方式执行此操作,但我有兴趣学习如何以“Drupal 方式”执行此操作。我想我必须使用视图和面板,但我不知道它们是否可以在这种情况下轻松实现。我尝试构建一些示例视图,但我认为手动创建代码会更快。
I use CCK in Drupal 6 and I need to build a search form in Drupal with 8-10 fields used as a filter. When the user submits the form I need to make a query on the DB applying filters and presenting the result on a table.
I know how to do this programmatically by building dynamically the SQL-where condition (joining node and content_type_xyz tables) but I would be interested in learning how to do it in the "Drupal way". I think I would have to use Views and Panels but I don't know if they can be easily implemented in situations like this. I've tried to build some sample views but I think to be faster in creating code by hand.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想要自定义搜索,你需要 IMO 做两件事:
实际上没有必要使用任何花哨的模块(这并不意味着您应该排除它们,但搜索是如此重要,以至于可以很好地使用基础知识来处理)。
使用上面的内容,您将获得一个具有所有功能的本机搜索表单,并且可以使用全局分页选项。
If you want custom searches you need IMO to do 2 things:
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.
如果您使用视图来执行此操作,您将只能使用 SQL 进行过滤。 Views 是一个 SQL 构建器,不包含任何“适当的”搜索功能。也就是说,听起来 Views 会做你想做的事;如果您在视图下创建过滤器,然后单击“公开此过滤器”,您会突然看到允许用户输入要过滤的内容的字段。
If you do it using views you will only be limited to the filtering you can do using SQL. Views is an SQL builder, and does not contain any 'proper' search functions. That said, it sounds like Views will do what you want; if you create filters under views and then click 'Expose this filter', you will suddenly see fields that allow the user to enter something to filter by appear.