自定义“notafield”如何?为视图 2 (Drupal 6) 定义的处理程序

发布于 2024-10-02 04:26:51 字数 720 浏览 4 评论 0原文

我只能找到预定义处理程序的文档。我想我必须重写处理程序类之一,但是我实际上必须重写哪些方法?我在某处读到 Views 2 的新处理程序需要向 Views 注册。在哪里以及如何?

我想定义一个不是数据库字段的字段,而是从其他字段计算的字段(未来日期/时间的倒计时)。

编辑: 我说的是一个自定义模块,它已经有两个 Views 2 字段(两个时间戳)。现在我想再定义两个字段,它们不是真正的数据库字段,而是根据真实字段计算的。所以我们在这里讨论 hook_views_data()。我不想为具体视图定义具体字段,而是定义模块用户可以用于任意视图的字段。

问题是,这些字段是如何定义的?如果我将该字段声明为 notafield 并设置非标准处理程序函数,我会在视图配置 GUI 中收到错误损坏/丢失处理程序。我可以从视图代码中猜测,我可能需要重写预定义处理程序类之一(而不是视图 1 中的全局函数)。但是我需要重写哪些方法以及将新类放在哪里以及视图如何知道在哪里可以找到该类?我找不到自定义字段处理程序或查询处理程序的任何文档。

编辑:
我记录了整个事情这里< /a>.

I can only find docs for predefined handlers. I guess I would have to override one of the handler classes, but which methods do I actually have to override? I read somewhere that new handler for Views 2 need to be registered with Views. Where and how?

I want to define a field which is not a DB field, but a field calculated from other fields (a countdown to a future date/time).

Edit:
I am talking about a custom module which already has two Views 2 fields (two time stamps). Now I want to define two more fields which are not really DB fields, but calculated from the real fields. So we are talking about hook_views_data() here. I don't want to define a concrete field for a concrete view, but the definition of a field which can be used by the user of the module for arbitrary view.

The question is, how are such fields defined? If I declare the field as notafield and set a nonstandard handler function I get an error in the views config GUI Broken/missing handler. I can guess from the views code, that I probably need to override one of the predefined handler classes (as opposed to global functions as with views 1). But which of the methods do I need to override and where do I put the new class and how does views know where to find the class? I can't find any documentation for custom field handler or query handlers.

Edit:
I documented the whole thing here.

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

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

发布评论

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

评论(2

不羁少年 2024-10-09 04:26:51

模块“views_customfield”可用于为视图创建自定义字段。

The module "views_customfield" can be used to create custom field for views.

冷弦 2024-10-09 04:26:51

我想通了(实际上是开发列表中的好人做到了):文档位于高级帮助中。只需安装视图和高级帮助模块即可。

I figured it out (actually the nice folks at the dev list did): The documentation is in the advanced help. Just install views and the advanced help module.

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