What would be the right setup in arguments to filter groupposts posted in the current group?

I've used "post in current group" in Filters but this ony worked for a block.
Appearantly Views consider me out of the group context when i use it for a page display, as no nodes show up.

Comments

merlinofchaos’s picture

Project: Views (for Drupal 7) » Organic Groups
Version: 6.x-2.2 » 6.x-1.1
Component: page displays » Og Views

This is an og question; I would hope that by now OG would have a default argument for this so that you can just select it, but it may not be there yet; I haven't installed og to see yet.

moshe weitzman’s picture

Status: Active » Fixed

it is called posts in current group (picg)

held69’s picture

Thanks guys for the interest.

As mentioned i've tried ' posts in current group' as a filter, but without the diplay i want.

This is what i'm trying to do:

-User gets on group-homepage
-User activates link in block-dispaly that says groupmessages.
-User gets on page-display with a summary of all the group messages.

I tried for example the filter:group member and got all the messages of groups that user is member of.
However filtering with posts in current groups didnt show up any messages at all.

This is why i guessed for arguments..

merlinofchaos’s picture

You'll note that neither Moshe nor I used the word filter.

held69’s picture

In the views i have installed (6.x-2.2) 'posts in current group' can not be found under 'arguments' or 'relationships'.

I can only find 'posts in current group' under 'filters' .

Should their be another place to look for 'posts in current group'

merlinofchaos’s picture

Under the argument select 'provide default' for the default action. A radio should appear containing the option.

held69’s picture

StatusFileSize
new155.34 KB

I looked around but couldn't find a radio button with 'posts in current group' under default argument.

For "my" options under 'provide default argument' you might want to check my attachment.

Thanks so far

held69’s picture

Status: Fixed » Active

Ok after a lot of searching after group context i have found a link of someone who with a similar problem. http://drupal.org/node/174563
The solution in this thread is a very clear step by step walkthrough, the only thing is, it is for drupal 5.

To what extend is this explanation useable for drupal 6?

1.For instance:
"Add Argument of "OG: Group Nid(s)" is this the same option as "OG: Group node"?

2.For the block menu php code is used as i'm not much of a coder, is this usable for D 6?

Finally:it would be really great if a clear step by step walk through, such as in the link above, would become available for Drupal 6.

held69’s picture

Still searching for this.

Nobody?

somebodysysop’s picture

StatusFileSize
new35.25 KB
new53.53 KB
new44.59 KB

I'm coming late to this party, but as I understand it, we are talking about two views. Both of them should be organic group views, that is, the results should be limited to a particular group. It looks like the same group, as far as I can tell.

So, you display the first view. On the first view is a link to the second view. Both of these views should be views within the same group? Correct?

posts in current group (picg) is a filter. My experience is that it works, but only if you are displaying the view within a group context. I would suggest that both of your views contain an organic group argument.

Attached are 3 images of an edit/add view screen. What I think you should do is add an argument to your views in order to limit each to a particular organic group.

The first (01) image displays what I select as a view argument: Organic groups: Group node

The 02 and 03 images display how I configure that argument. Note that I use the group nid ("gid") as my argument for the view.

So, that means that your link to the second view must contain the group nid in the url as an argument. Are you doing this?

clemens.tolboom’s picture

Yesterday I 'discovered' how to do this for a block view to the 'more' page view. My block is build in an OG context so the filter 'Posts in current group' is doing fine. But for the more link I had to add PHP into the blocks footer instead of a normal 'more' link.

$g_node=og_get_group_context();
if (isset($g_node)) {
  $gid=$g_node->nid;
  return l( t('More'), 'my-page/' . $gid);
}

The views page has the argument construct mentions in #10

@held69 : you could start a page about this :)

Hope this helps.

held69’s picture

To SomebodySysop,

Both of them should be organic group views, that is, the results should be limited to a particular group. It looks like the same group, as far as I can tell.

Correct.

So, you display the first view. On the first view is a link to the second view. Both of these views should be views within the same group? Correct?

Correct.

After your suggestions i have tried doing the following:
1.Create a block-view that stays in group context using arguments
2.Create a page display that displays the groupmessages of the 'current group'
3.Tried to place a link in the block view that leads to the page view

1.Create a block-view that stays in group context using arguments
I have tried to apply the arguments setup as displayed in your screenshots.
However applying your steps resulted in no display at all for the block.

I have got it working though.
I used the arguments configuration as in the calender view.
see jpg 1 post 14

I'm confused about the filter setting. I dont know how to filter a page-view that displays all
group messages for a particular group. For now i'll set the filter to a 'node type' that is only posted once in my test group.(just to limit the amount of results in the block)
Fields setting is set to 'title'.

2.Create a page display that displays the groupmessages of the 'current group'.
This part was fairly easy. I just followed your screenshots.
Should 'Relationships' in this view be configured as well? For now mine is not.
Path is:http://www.mysite.com/og/content/%/groupmessages

3.Tried to place a link in the block view that leads to the page view
I didn't got this one working.
I'm still a bit confused here. As views doesn't allow a normal menu entry with % in it.
It would be great to have something like link display, like in the calender view. see jpg 3 post 14

But after my former posting http://drupal.org/node/358951
I use this:
In the footer (see jpg 2 post 14)of the block display under basic settings i place a plain html link.
See also jpg 4.
As a result i get a link in my block "groupmessages", it is not active though.
I can click on it but nothing happens.

So to resume this long post.
Creating a block display: works good as i can tell, didn't set it up though as you mentioned
Creating a page display: just followed the steps.
Creating a link:no succes here

held69’s picture

To clemens

Your help is much appreciated.

Thanks

held69’s picture

StatusFileSize
new41.06 KB
new13.42 KB
new11.68 KB
new47.14 KB

mmm the attachments...

somebodysysop’s picture

I think I see your problem. In your Footer you are using Full HTML and assuming that by using the '%' token the argument will pass through. This is not correct.

You should construct your footer as php code, then put in something like this to get the correct gid:

  // This assumes an existing group context
  $group_node = og_get_group_context();
  $arg = $group_node->nid;

  $link = l('Go here', 'YourViewPage/'.$arg);
  return $link;

In case your current view isn't in group context, you can get the argument that was used to construct by using $view->args.

So, and I'm just guessing here because I don't really use this:

  // First, get the argument from the current view
  $view = $GLOBALS['current_view'];  // I don't know if this will work because I don't know where this is set.
  $arg = $view->args[0];  // this will get the first argument.

Or, even more easily:

  // Get the argument from the url
  $arg = arg(1); // assuming that arg(1) is the node id argument in your current view

Hope this helps.

held69’s picture

Thanks a lot sofar.

I have been trying out and have some questions.
Right now the link is active, however i get a page not found.

1.How should i define the path of my page-view in php.
What to put in the 'Yourpageview' part?

Should i put here:
-The url of the page-view
-Part of the url of the pageview
-Just the title of the page-view

My current url of the page display is: og/content/%/groupmessages.

Like

$link = l('Go here', 'og/content/%/groupmessages/'.$arg);
  return $link;

or

$link = l('Go here', 'titleofmypage/'.$arg);
  return $link;

2.
The second and third code block dont have a

  $link = l('Go here', 'YourViewPage/'.$arg);
  return $link;

part

Can i just paste this part at the bottom of the code block before the ?>sign,
to finally paste the part as a whole in the footer of the block view.

somebodysysop’s picture

My current url of the page display is: og/content/%/groupmessages.

$link = l('Go here', 'og/content/'.$arg.'/groupmessages/');
  return $link;
held69’s picture

Yessssss, i think i really got it!

I had to alter some a little bit.

In my page display i didn't make any use of the filter 'post in current group'.
As an argument in my display i didn't use 'groupnode' which didn't give me any result, but
organic groups:groups, with Group nodes as the validator and node id as the argument type.

Ron thanks a lot! Let me know where you at and i'll come over and give you a great hug :)
Great stuff.

I'll trie and make a nice walkthrough for other non coders and 'views' starters like me.

Maybe a silly question, but if i would want to have another link under my current 'groupmessages link' can i just use the following code and paste it under the 'groupmessages' link code?

$link = l('This time go here', 'og/content/'.$arg.'/agendaitems/');
  return $link;
somebodysysop’s picture

Thank you very much. I'm not sure what you mean by 'groupmessages' link code, but try it and see what happens.

held69’s picture

Sorry for not being clear enough.

My current code in the block footer looks like this:

<?php
  // This assumes an existing group context
  $group_node = og_get_group_context();
  $arg = $group_node->nid;

$link = l('groupmessages', 'og/content/'.$arg.'/groupmessages/');return $link;
  

?>

My question is what to do if i want to create another link under the 'groupmessages' link.
My goal is to display several links, e.g groupmessages, agenda items, events.

Without succes i have tried several combinations.
One of them:

<?php
  // This assumes an existing group context
  $group_node = og_get_group_context();
  $arg = $group_node->nid;

$link = l('groupmessages', 'og/content/'.$arg.'/groupmessages/');return $link;
$link = l('agenda items', 'og/content/'.$arg.'/agendaitems/');return $link;

?>

Hope this makes sense.

somebodysysop’s picture

Then, you need to return both links in some sort of html. For example:

  // This assumes an existing group context
  $group_node = og_get_group_context();
  $arg = $group_node->nid;

$link01 = l('groupmessages', 'og/content/'.$arg.'/groupmessages/');
$link02 = l('agenda items', 'og/content/'.$arg.'/agendaitems/');

$link = "<ul><li>$link01</li><li>$link02</li></ul>";

return $link;
held69’s picture

mmm still working something out one last thing...

I have been trying to display the block (see comment #12 1.) on certain 'grouptypes' only.

So i have taken the code snipppet beneath and placed this under the visibility settings of the block under (admin/build/block).

<?php
$match = FALSE;
$types = array('page' => 1, 'story' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type])) {
    $match = TRUE;


  }
}
return $match;
?>

The code snippet works fine. However when i now click a link the block, the block looses groupcontext and does not display on the next page.

Without result i have tried to put these functions together.
Is there any chance to merge the groupcontext function mentioned under #21 and the code snippet above?

Thanks.

held69’s picture

Status: Active » Fixed

placed this code in the visibility settings under administer-blocks.

<?php
//check og module exists
if (module_exists('og')){

//check we've got a group, rights to view the group,
// and of type "group_type" - change this to whichever group you want to restrict the block to
//or remove the condition entirely
if (($group = og_get_group_context()) && node_access('view', $group) && ($group->type == 'bk') ) {

  return TRUE;
}
}
?>

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.