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
<?php
global $current_view;
$current_view->args[0]=$node->nid;
$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:
<?php
$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!
Comments
How do you handle access
How do you handle access permissions similar to OG?
CCK group or organic groups
Thank you for this. I am completely new to Drupal and I was wondering if you could help elaborate on this further to help me get this going. I had been considering using organic groups but it sound like you think it will be better to create a CCK group as described above. Basically, I need to create a system where users can assign themselves to a group (each user can only belong to 1 group) or 1 user creates a group and assigns users to this group.
How would you suggest I go about doing this? For instance, what type of fields would I need to create in the "group" content type for users to be able to select the group? Would I need a nodeprofile field in the "group" content type? When you said above "Each content type will need the same node reference field", which node reference field are you referring to - the one in the "user profile" content type or the "group" content type?
As you can see, I've got several questions (sorry). I don't really know if it will be too much trouble to ask if you could post a step by step guide(?) I will really appreciate it.
Thank you again in advance.
Remy.
Thanks for information...
Thanks for information...
OG and OG User Roles
I just started using Drupal about 2 weeks ago and I'm learning a lot. I'm building a clan-related website at http://www.warhawkclans.com (note, you can go there and sign up if you like, but I'm still working on/designing it).
Anyhow, I needed to have the ability to create a "clan," set a clan leader, and set clan members. After scratching around with TAC and OG, I found that regardless of whether a user was part of the "clan" or not, anyone could read clan documents. After lots of reading, I finally found out about OG User Roles.
It lets you do the following things (and probably a lot more):
Now, the interesting bit is that when a user role is set in the context of the group/clan, their access permissions only apply in that group/clan.
For instance, currently I don't set a site-wide user role, but I do set "clan leader" for a clan creator and "clan member" for, obviously, a clan member.
In the user roles for clan leader I have some pretty heavy permissions, like "edit page", etc. which, without OG User Roles, would allow any clan leader the ability to edit any page, NOT WHAT I WANT!!!
But, with OG User Roles, the clan member only has that permission for any content that is created by that clan.
I don't recall any inherent option that says "only allow a site user to belong to one group," but I'm sure a module exists for that, or can easily be implemented in PHP (another thing I'm learning - fun!)
I'm still working on my design/architecture, but it's looking promising.
I know this article is about CCK, but I haven't looked at that yet!
OG
Sounds cool. OG is actually pretty sweet, I was looking into it recently and there are quite a lot of modules for it. I even recall a module that did force users to only belong to one group, as well as assigning users to a group upon registration which you may want to look into.
This Node Reference option is a good one for small sites, where you won't really have many "groups", I think.
Prepopulate
Another fun thing you can do with this is use the Prepopulate module, which can definitely be handy if you have a lot of groups.
Or this module - Field thief
Or this module - Field thief