Creating "Groups" Using CCK, Views, Node Profile and Node Reference in Drupal


Being an avid user of CCK and Views, I decided to try essentially creating "groups" using them and the CCK node reference. This isn't going to be a step by step how-to, but more of a general proof of concept.

The modules used in order to achieve this functionality:

The idea here is we're going to create a content type to act as the group's main page. For instance, let's say we create a CCK called "group". We'll have the title of the group and a description.

Now we need to set up nodeprofile. For more info on nodeprofile and how it works, check out the documentation. There's also a great step by step tutorial on creating a nice user profile with the nodeprofile set of modules. Basically, it allows for users to be treated as nodes. So, let's say we create a node called "user profile". We'll have fields like name, location, picture, etc. We'll also add a CCK node reference to this node, and and check "group" as a reference. Set it as a nodeprofile.

Now, when a user is created and their nodeprofile is created, you can choose which "group" content type to reference the user to.

There's lots of things that can be done from here, but let's assume we want to create a list of all the users associated with a specific group. We would create a view called "group_user_list", add the correct Node Reference as an argument, filter it by the nodeprofile content type, and add it to the "group" content type. In my situation, I embedded the view directly in node-group.tpl.php

global $current_view;
$view1 = views_get_view('group_user_list');
print (views_build_view('embed', $view1, $current_view->args, false, false));

You can also create other content types to associate with the group. A CCK event type, blogs, etc. Creating views to add them onto the main group page is pretty straight forward. Each content type will need the same node reference field, and when creating the view, use the node reference field as the argument. You will need to add:

$args[0] = arg(1);

in the "Arguments Handling Code" section of the view in order to get things to display properly. Voila, groups without using organic groups!




I am using CCK, Views and Location modules (

I have created several types of content shared with CCK fields and now I want to use filters in views2 search to create blocks that allow users to search.

I want users to search for content in user functions, key words etc, but for me is that users can find content by the location of the author.

I know I can add "location" (country, province, city, street, postal code, etc) for each type of content and ask authors to add your address every time that users can scraps information about the location of them in each Post article. ... but this is nonsense ... What if the author wants to publish 20 articles? are supposed to write their address 20 times? The authors should add the address (es) to your user profile (I am using the content module profile) only once ....

Has anyone had problem like this before? Please let me know if there are things you can do ...

Thank you very much.

Add new comment