如何使用当前显示的节点来过滤该节点页面上的块级视图?
我通过节点引用设置了父/子关系。子记录可以有一个从节点引用字段中选择的父记录(这是可选的——我也可以有无父记录)。
我创建了一个视图块,显示在父页面的内容下方。它将显示该父节点的所有子节点的表格。问题是,现在它显示每个子节点。我需要过滤它以仅显示父级。
我需要做的是向该视图添加一个过滤器,以有效地表示“仅显示分配给此页面上显示的父级的子节点”。
因此,我需要以某种方式获取当前显示节点的 Nid(在显示此块的所有情况下,这将是父节点),并在我的视图中的过滤器中使用它。
我到底该怎么做呢?
(最初我为此使用了附件视图(如 this page 指示)。我创建了一个页面视图来显示父级,然后创建了一个附件视图来显示所有子级,然后将其附加到页面视图下,但设置起来几乎是荒谬的。由于许多其他原因,这是不受欢迎的——主要是我的父级现在有两个专用 URL、它自己的节点级页面以及由此视图创建的类似页面。)
使用 Drupal 6.15。
I have parent/child relationship set up via Node Reference. A Child record can have a Parent record selected from a Node Reference field (this is optional -- I can have Parent-less Children as well).
I've created a Views block to appear on the Parent pages, below the content. It's going to show a table of all the Child nodes for that Parent. Problem is, right now it shows every Child node. I need to filter it for just the Parent being displayed.
What I need to be able to do is add a filter to this View to effectively say, "Only show the Child nodes that are assigned to the Parent being displayed on this page."
So, somehow I need to be able to get the Nid of the currently displaying node (which will be a Parent, in all cases when this block is displayed), and use that in a filter in my View.
How exactly can I do this?
(Initially I used an attachment view for this (as this page instructs). I created a page view to display the Parent, then an attachment view to display all the Children, then attached that under the page view. This worked, but it was almost absurdly complicated to set up, and it was an undesirable for a number of other reasons -- primarily that my Parent now has two dedicated URLs, it's own node-level page, and the similar page created by this view.)
Using Drupal 6.15.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了。您为父关系添加一个参数,然后提供默认值“来自 URL 的节点 ID”。
I found it. You add an argument for the Parent relationship, then supply a default value of "Node ID from the URL."