简体   繁体   English

Drupal:当节点的cck字段具有该用户的配置文件节点标识时,显示与该配置文件相关的节点

[英]Drupal: Showing nodes related to a profile when a cck field of those nodes have the profile nodeid of that user

I need to show all nodes of a specific nodetype, related to the profile node of each user, inside a certain page. 我需要在特定页面内显示与每个用户的配置文件节点相关的特定节点类型的所有节点。 This is what I have: 这就是我所拥有的:

  • Users with their userids (example uid A) 具有其用户标识的用户(示例uid A)
  • A Profile node for each user (example nodeid B) 每个用户的个人档案节点(示例节点ID B)
  • Several reg nodes with a cck field that contains the nodeid of the profile node (example cck field C) 多个reg节点,其cck字段包含配置文件节点的nodeid(示例cck字段C)

I need to show inside a page all reg nodes that have inside that cck field B the nodeid A. For each user. 我需要在页面内显示在cck字段B中具有节点ID A的所有reg节点。对于每个用户。 So I enter a page usersregnodes/uidA and see all regnodes that are related to that user because in their cck field C they´ve got the node nodeidB that´s the profile nodeid of that user. 因此,我进入一个页面usersregnodes / uidA并查看与该用户相关的所有regnode,因为在其cck字段C中,他们获得了节点nodeidB,即该用户的配置文件nodeid。

I´m struggling with relationships and arguments. 我在关系和争论中挣扎。 So far, I think that I should create a relationship Node:Content Profile. 到目前为止,我认为我应该创建一个关系Node:Content Profile。 The filter should be the reg nodetype. 过滤器应为reg节点类型。 And the argument should be the userid (?). 并且参数应为用户标识(?)。 I can´t make this work, because all combinations and try and error that I´ve tried results in blank results. 我无法完成这项工作,因为我尝试过的所有组合以及尝试和错误都会导致结果空白。

I would really appreciate your help! 我将衷心感谢您的帮助! THANKS! 谢谢! Rosamunda 罗萨蒙达

You could use a view to get this done. 您可以使用视图来完成此操作。 The trick is to change the argument validation. 诀窍是更改参数验证。

If I got it right you need to pass the uid as an argument to a view, but get the nodes that reference the nid of content profiles of that particular uid . 如果我得到了它的权利,你需要通过UID作为参数传递给一个视图,但得到引用的特定UID的内容配置文件的NID的节点。

To achieve this you need to build a view and set an argument with a custom validator. 为此,您需要构建视图并使用自定义验证器设置参数。

Build the view as follows: 如下构建视图:

  1. It's a node view; 这是一个节点视图;
  2. Set up an argument. 设置一个参数。 Choose the node reference field that contains the nid for your argument; 选择包含您的参数nid的节点引用字段;
  3. In the argument configuration screen, look for "validator options"; 在参数配置屏幕中,查找“验证程序选项”;
  4. Select "PHP code" instead of "Basic Validation"; 选择“ PHP代码”而不是“基本验证”;
  5. Use the following code (don't use php opening and closing tags): 使用以下代码(不要使用php的开始和结束标签):

     $prev_arg = $handler->argument; $handler->argument = content_profile_load('content_type_name', $prev_arg)->nid; return $handler->argument; 

This way you should be able to change the value of the argument from the uid into the content profile nid and get the results of the view filtered by the nid. 这样,您应该能够将参数的值从uid更改为内容概要文件nid,并获得由nid过滤的视图结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM