Hello Everyone,

What I'm trying to accomplish may seem simple. But I can't figure out a way to set it up.

I have 2 content types, each content type is a group post, within the same group, that need to be linked using cck node reference.

When creating a group post, I see that the groups nid is incorperated into the URL. ( node/add/content_type?gids[]=10 )

Is there anyway to filter a node reference select box to show only posts in that group (mentioned in the URL of the add/edit form)?

Comments

jpbaldiga’s picture

I figured out a way to do it, it may be a little sloppy tho.

Here's what I came up with.

I created a view with a group argument to use for the select list.

I had a hard time passing the arguement to the add/edit form so I figured global would be a good way to go.

In the views argument settings, I typed this in the "provide default argument using php code"

$grpnum = $GLOBALS['_SERVER']['QUERY_STRING'];
$trimmed = trim($grpnum, "q=node/add/content_type&gids[]=");
return($trimmed);

Basically I pull the current URL, discard everything I don't need using the trim function, and I'm left with the group nid to filter my view :)

Hope someone finds this helpful one day.

pablov2’s picture

@jpbaldiga

I want to do same, I want to filter a node reference to show only nodes in that group... Have you found any solution??

intervalle’s picture

if you are selecting the filter "Organic groups : OG: Posts in current group" the view shows - like the filter says - only posts in the current group.
Hope that helps ....

capellic’s picture

@intervalle is correct. You don't need to do anything special, just add that filter.