在 Drupal 6 中阻止相对于其所在页面的视图内容

发布于 2024-10-20 11:08:38 字数 345 浏览 9 评论 0原文

我想让视图块的内容显示与我所在页面相关的内容。例如,我有一个内容类型“父”,它有许多与其相关的“子”类型的节点,因此在“父”节点上,我想显示块中的所有“子”。

没那么复杂,但我就是无法让它工作。我一直在使用节点相对性模块来设置父子关系,然后尝试在视图中添加参数来过滤子节点。问题是我无法获取从子节点保存的父 ID + 如果不使用 URL 参数,我也无法真正获取我所在页面的 ID(父 ID),这意味着没有干净的网址。

我尝试将父节点的 ID 保存为子节点的分类术语。问题是我希望在创建新节点时自动设置父子关系(通过在创建新节点时使用当前页面的 ID 作为参数)。

也许我从错误的角度看待这个问题......有人对此有任何见解吗?

I want to make a Views block's content show things that's related to the page I'm on. For example I have a content type 'Parent' that has many nodes of type 'Child' related to it, so on the 'Parent' node I want to show all 'Children' in my block.

Not that complicated but I just can't get it to work. I've been using the Node Relativity module to setup the Parent-Child relationship and then I tried adding an argument in the View to filter the Child nodes. The problem with this is I can't get the Parent ID saved from the Child node + I can't really get the ID of the page I'm on (the Parent's ID) either without using a the URL argument, which means no clean URLs.

I experimented with saving the ID of the parent as a taxonomy term for the Child nodes. The problem with this is I want the Parent-Child relationship to be setup automatically when creating a new node (by using the current page's ID as a parameter when creating a new node).

Maybe I'm looking at this from the wrong angle though... Does someone have any insight in this?

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

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

发布评论

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

评论(2

第几種人 2024-10-27 11:08:38

您想要的是视图附加,以便在给定节点上您可以显示与该节点相关的内容。查看 Mustardseed Media 的此食谱,以进行相关内容创作和制作。看待事物相当容易。

What you want is views attach so that on a given node you can show things related to that node. Check out this recipe from Mustardseed Media for making related content creation & views things rather easy.

旧人 2024-10-27 11:08:38

视图附加可以做到这一点,但它不是附加到节点内容而不是作为一个块吗?

要在块中执行此操作,请创建一个视图块,并将父节点引用 id 作为视图参数。

然后选择提供视图默认参数。对于视图 2,我认为您可以只使用“从 URL 提供节点 id”。如果这不起作用,请使用 PHP 提供参数并将其输入为 php:

<?php if (arg(0) == 'yourcontenttype' && arg(1) != '') {  return arg(1); } ?>

让我知道这对您来说如何工作。

Views attach would do it, but doesn't it attach to the node content rather than as a block?

To do it in a block, create a views block with the parent node reference id as the views argument.

Then select to provide the views default argument. With views 2 I think you can just use "Provide node id from URL". If that doesn't work then provide the argument with PHP and enter this as the php:

<?php if (arg(0) == 'yourcontenttype' && arg(1) != '') {  return arg(1); } ?>

Let me know how that works for you.

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