如何在 Drupal 中编写自定义报告
Drupal 中创建报告的“正确”方法是什么?我希望使用一个视图,但运气不太好。我的目标是创建一个包含三个字段的行表:用户名、位置、志愿者小时数总和。一旦我完成这部分工作,我计划公开位置和日期的过滤器。
Views Calc 只允许您按一个字段进行分组。我了解 Crystal Reports 和 MSSQL Reporting Services,并且希望为 Drupal 找到类似的东西。是否有框架、示例或模块可以帮助解决此问题,或者我是否需要编写一个实现views_alter_SQL 挂钩的自定义模块来获取每个报告所需的数据?
编辑:我最终让它与 BIRT 报告一起使用,这提供了比视图所能允许的更多的功能。代码在我的博客上: http://nicholaiburton.com/blog/ 2010/为 Drupal 创建自定义报告
What's the "right" way in Drupal to create reports? I was hoping to use a view but am not having much luck. My goal is to create a table of rows containing three fields: user name, location, SUM of volunteer hours. Once I have this part working, I plan to expose filters for Location and Date.
Views Calc only allows you to group by one field. I know Crystal Reports and MSSQL Reporting Services and I was hoping to find a similar kind of thing for Drupal. Is there a framework, examples, or a module to help with this, or do I need to write a custom module implementing the views_alter_SQL hook to get the desired data for each report?
EDIT: I ended up getting it to work with BIRT reports, which gave a lot more power than Views could allow. Code is on my blog: http://nicholaiburton.com/blog/2010/creating-custom-reports-for-drupal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以实现views_query_alter,但您可能最好实现自定义视图字段处理程序,因为我假设您的user.uid加入到hours.uid。这可能是您最好的长期解决方案。
您需要做的只是告诉视图您的表如何连接并定义总小时数的处理程序。您可以找到帮助/文档 -> http://views-help.doc.logrus.com/help/views/ API
You could implement a views_query_alter but you might be better off implementing a custom views field handler, because I assume that your user.uid joins to hours.uid. This will probably be your best long term solution.
All you'd need to do is just tell views how your tables join and define the handler for the total hours. You can find help/docs -> http://views-help.doc.logrus.com/help/views/api
无论如何,对于志愿者小时数的总和,您需要构建自定义模块,因此构建自定义查询比通过挂钩将自定义字段附加到视图更简单......
in any way, for Sum of Volunteer hours you need to build custom module, so building custom query more simpler, than attaching custom field to Views via it's hooks...