视图 3 关系处理程序

发布于 2024-11-01 16:00:10 字数 542 浏览 1 评论 0原文

我正在尝试为 Drupal 7 中的 Views 3 编写一个关系处理程序,但我什至无法开始。

基本上,我有一堆各种类型的节点,它们都附加了相同的字段。该字段是链接到 Civicrm 联系人的参考字段 - 但这并不重要,因为本质上这些字段只包含整数。

现在,假设我有一个内容类型为“故事”的节点,其引用字段包含整数,哦,假设为 55。此外,还有一些内容类型为“新闻”的节点也包含引用 ID 55

。想要构建一个位于故事页面上的块视图,该视图读取节点的 nid 作为其参数,然后通过关系发现包含与自身相同的引用整数的所有其他节点。

(在我的脑海中,sql 看起来像:SELECT n.nid FROM node n INNER JOIN node n2 ON n.reference = n2.reference [假设,为了简单起见,字段数据是保存在节点表中])。

如何创建满足这种关系的视图处理程序?我能找到的唯一文档是views api,它适用于版本2,而不是版本3,而且完全没有帮助。阅读各种模块的视图处理程序也没有帮助,并且网络上的视图教程几乎不存在。

I am trying to write a relationship handler for Views 3 in Drupal 7, but am failing even to begin.

Basically, I have a bunch of nodes of various types all with the same field attached to them. This field is a reference field linking off to a Civicrm contact - but that's not important, as essentially these fields just contain integers.

Now, let's say I have a node of content type 'story', and its reference field contains the integer, oh, let's say 55. In addition, there are nodes of content type 'news' which also contain the reference ID 55.

I want to build a block view, that sits on the story page, that reads in the node's nid as its argument, and then through a relationship it discovers all other nodes that contain the same reference integer as itself.

(In my head, the sql looks something like: SELECT n.nid FROM node n INNER JOIN node n2 ON n.reference = n2.reference [Assuming, for the sake of simplicity, the field data is kept in the node table]).

How do I create a Views handler that caters for this relationship? The only documentation I can find is the views api, which is for version 2 and not 3, and besides is utterly unhelpful. Reading various module's views handlers is not helping either, and views tutorials on the web are almost non-existent.

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

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

发布评论

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

评论(1

攒眉千度 2024-11-08 16:00:10

你在做什么?有什么问题吗?听起来您在这里拥有所需的一切... nid 作为参数,参考字段作为关系。你的过滤器设置了什么?您使用什么类型的显示器?您可以让块显示一些信息,而不进行排序、参数或关系,然后使用 devel 模块,您可以将块的 tpl 文件更改为 dpm($views) 并查看您可以访问哪些信息。

让我们知道您到目前为止已配置的内容以及您的结果(如果有)。请记住,您可以在预览中使用 nid 作为参数,因此如果 nid 是 213,您可以在预览字段中键入 213(确保显示设置为您正在谈论的块)并查看会出现什么。

祝你好运。

What are you doing and what is the problem? It sounds like you have everything you need right here...the nid as an argument and the reference field as a relationship. What are your filters set to? and what display type are you using? You could just have the block display some information without sorting, arguments, or relationships and then using the devel module you can change the tpl file for the block to dpm($views) and see what information you have access to.

Let us know what you have configured so far and what your results are if any. Remember that you can use the nid as an argument in the preview, so if the nid is 213 you can type 213 in the preview field (make sure the display is set to the block you are talking about) and see what comes up.

Good luck.

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