结合数据和表格
我正在 Drupal 7 中编写一个模块,它使用主题('table')显示数据库中的一些数据。 它工作得很好,现在我想使用以下命令添加一些按日期和类别过滤的数据 文本字段和选择框。
我如何将这两者结合起来?
I am writing a module in Drupal 7, that shows some data from database using theme('table').
It works great and now I would like to add some data filtering by a date and a category using
textfield and a select box.
How do I combine those two?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的主题函数根据您作为参数传递的数组返回格式化输出。因此,您必须先过滤数组的内容,然后再将其传递给主题函数。使用 Drupal 的 FAPI 创建表单元素,在表单的提交函数中传递页面查询字符串中所需的参数,并使用这些值来过滤/创建数组,然后再将其传递给主题函数。通常,您使用这些参数来过滤对数据库本身的 SQL 查询。
作为如何实现此提交功能的示例: 如何在 Drupal 中进行表单自引用?或者还有其他选择吗?
另外,请查看 Drupal 的核心搜索和 dblog 模块作为参考。数据库日志记录中的报告页面有一个过滤器,搜索模块实现了传递参数的搜索。
Your theme function returns the formatted output according to an array you pass as a parameter. So you have to filter the contents of your array before passing it to the theme function. Create your form elements using Drupal's FAPI, in the submit function of your form pass the parameters needed in your page's query string and use these values to filter/create your array before passing it to your theme function. Usually you use these parameters to filter your SQL query to the database itself.
As an example on how to implement this submission function: How to make a form self referencing in Drupal? Or any other options?
Also, check out Drupal's core search and dblog modules as references. The reports page in Database Logging has a filter and the Search module implements a search passing parameters.