Hi All,

I expect this is me missing something really obvious. I am trying to create a view that will display only a given content type for the current group being shown. There is more than one content type for the groups, hence the need for a filter.

I currently have a filter that can filter and display nodes of the type I want, nodes that are only for groups, but I cannot get it to display for the current group.

I have now attempted to use an argument with the path being set to:

/og/%/mytype

I thought I would be able to select an argument that is the group name. But whatever I select for an argument results in the view being empty.

Can someone tell me what I am doing wrong please?

Regards,
Nick

Comments

uzbekjon’s picture

In Drupal 5 you have "OG: Posts in current group" option in filters section. I am sure there is the same for Drupal 6

-------------------------------
Read Drupal tutorials & tips at Drupal HowTos Collection

nickbits’s picture

Hi uzbekjon,

Thanks for the reply. Yes you do have that option in the filters for Drupal 6, however using that I get a blank page.

Not sure if the following info will help. I have redirected, using URL Aliases, the og to groups. so to get to a group you now go to:

mysite.com/groups/film-club

for example. This works fine, I can see each group and the posts in them.

I want to use events and calenders in the groups. I know there is an OG Calender module. This uses the event module which I want to avoid. Firstly as many people say it probably will not be developed much further and the Calender module is taking over. Secondly because I am already using the calender module with feeds API to pull in events from elsewhere.

So what I want to be able to do is to go to the page:

mysite.com/groups/film-club/events

and have that show just the events. A list will be fine at the present. I can get it to display all events from all groups, but no matter what filter or argument I try, I cannot get it to select only the group given in the URL (film-club for example).

Not sure if I am going about this the best way!!!

Thanks,
Nick

----------------------------------
Nick Young
www.nickbits.co.uk / www.drnick.me.uk

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

nickbits’s picture

Anyone?

----------------------------------
Nick Young
www.nickbits.co.uk / www.drnick.me.uk

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

Rustan’s picture

I have the exact same problem, please tell if you find out how to fix it.

nickbits’s picture

Hi,

No still no luck!

Nick

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

WorldFallz’s picture

Can you be more specific about what the problem is? I have no problem getting the view working with 2 arguments: "organic groups: groups" and "node: type".

nickbits’s picture

Hi,

There are two problems , but think if I can get one sorted I can figure the other out. Essentially what I want is to be able to have a sep. page to show only private posts. So for example if I go to groups/group1/private it would display private posts for group1 only.

Nick

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

WorldFallz’s picture

There isn't an argument for this, but there is a filter. Just change the url to og/%/%/private and add the 'organic groups: post: public' filter and set it to 'false'.

nickbits’s picture

Hi,

Thanks for that. I have now tried that and get a list of the groups and not the posts. It may be me, but why do you use two "%"?

If I use og/%/private I get private posts shown, but now any blocks that were attached to that group do not appear.

Cheers,
Nick

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

WorldFallz’s picture

There are 2 "%" because you should be using 2 arguments before the "private": "organic groups: groups" and "node: type". As for the blocks, you may have to adjust the block visibility settings for the missing blocks at admin/build/block.

ludo1960’s picture

nickbits’s picture

@WorldFallz, @ludo1960, thank you both for the help. I have managed to get part of what I want working absed on the information you have both provided. I can now go to "og/1158/private" and it will display private posts for that group. What I cannot get working, is instead of having the group id (1158) is to have the group name (i.e. filmclub). I know this is probably simple, but cannot for the life of me see where I am going wrong.

Have included my view below.

Regards,
Nick

$view = new view;
$view->name = 'og_private';
$view->description = 'Private Posts for OG';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'group_nid' => array(
    'label' => 'Group node (post)',
    'required' => 0,
    'id' => 'group_nid',
    'table' => 'og_ancestry',
    'field' => 'group_nid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'created' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'group_nid' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '%1',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'og_group_types',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'group_nid',
    'table' => 'og_ancestry',
    'field' => 'group_nid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'faq' => 0,
      'image' => 0,
      'aggregation_feed' => 0,
      'aggregation_item' => 0,
      'acidfree' => 0,
      'book' => 0,
      'event' => 0,
      'event_feed' => 0,
      'event_feed_item' => 0,
      'feed' => 0,
      'group' => 0,
      'group_item' => 0,
      'headerimage' => 0,
      'local_directory' => 0,
      'news_item' => 0,
      'news_newburytoday' => 0,
      'page' => 0,
      'profile' => 0,
      'story' => 0,
      'travel_feed' => 0,
      'travel_feed_item' => 0,
      'xml_weather_feed_item' => 0,
      'xml_weather_feed_parser' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '8' => 0,
      '5' => 0,
      '1' => 0,
      '7' => 0,
      '6' => 0,
      '4' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'image_size' => array(
      '_original' => '_original',
      'thumbnail' => 'thumbnail',
      'preview' => 'preview',
    ),
    'validate_argument_is_member' => 1,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'status' => array(
    'operator' => '=',
    'value' => '1',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status',
    'table' => 'node',
    'field' => 'status',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'is_public' => array(
    'operator' => '=',
    'value' => '0',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'is_public',
    'table' => 'og_ancestry',
    'field' => 'is_public',
    'relationship' => 'none',
  ),
  'picg' => array(
    'operator' => '=',
    'value' => '',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'picg',
    'table' => 'og_ancestry',
    'field' => 'picg',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'teaser' => 1,
  'links' => 1,
  'comments' => 0,
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'og/%/private');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

ludo1960’s picture

..change group_nid to group_path you should get "filmclub"

WorldFallz’s picture

Not sure about that-- i used a relationship to grab the node title of the group node for the argument. Here's the export of the view i got working:

$view = new view;
$view->name = 'og_private_nodes';
$view->description = 'Private nodes by content type for groups.';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'group_nid' => array(
    'id' => 'group_nid',
    'table' => 'og_ancestry',
    'field' => 'group_nid',
  ),
));
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'title' => array(
    'default_action' => 'summary asc',
    'style_plugin' => 'default_summary',
    'style_options' => array(
      'count' => 1,
      'override' => 0,
      'items_per_page' => '25',
    ),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 0,
    'limit' => '0',
    'case' => 'none',
    'path_case' => 'none',
    'transform_dash' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'group_nid',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'blog' => 0,
      'poll' => 0,
      'deadwood_category' => 0,
      'deadwood_item' => 0,
      'image' => 0,
      'forum' => 0,
      'project_project' => 0,
      'project_issue' => 0,
      'panel' => 0,
      'book' => 0,
      'definition' => 0,
      'document' => 0,
      'feedtest' => 0,
      'feedtest2' => 0,
      'gallery' => 0,
      'group' => 0,
      'location_type' => 0,
      'page' => 0,
      'profile' => 0,
      'story' => 0,
      'term' => 0,
      'test' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '8' => 0,
      '7' => 0,
      '6' => 0,
      '5' => 0,
      '3' => 0,
      '2' => 0,
      '4' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_is_member' => 0,
    'validate_argument_project_term_vocabulary' => array(
      '6' => 0,
    ),
    'validate_argument_project_term_argument_type' => 'tid',
    'validate_argument_project_term_argument_action_top_without' => 'pass',
    'validate_argument_project_term_argument_action_top_with' => 'pass',
    'validate_argument_project_term_argument_action_child' => 'pass',
    'validate_argument_php' => '',
  ),
  'type' => array(
    'default_action' => 'summary asc',
    'style_plugin' => 'default_summary',
    'style_options' => array(
      'count' => 1,
      'override' => 0,
      'items_per_page' => '25',
    ),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'blog' => 0,
      'poll' => 0,
      'deadwood_category' => 0,
      'deadwood_item' => 0,
      'image' => 0,
      'forum' => 0,
      'project_project' => 0,
      'project_issue' => 0,
      'panel' => 0,
      'book' => 0,
      'definition' => 0,
      'document' => 0,
      'feedtest' => 0,
      'feedtest2' => 0,
      'gallery' => 0,
      'group' => 0,
      'location_type' => 0,
      'page' => 0,
      'profile' => 0,
      'story' => 0,
      'term' => 0,
      'test' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '8' => 0,
      '7' => 0,
      '6' => 0,
      '5' => 0,
      '3' => 0,
      '2' => 0,
      '4' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_is_member' => 0,
    'validate_argument_project_term_vocabulary' => array(
      '6' => 0,
    ),
    'validate_argument_project_term_argument_type' => 'tid',
    'validate_argument_project_term_argument_action_top_without' => 'pass',
    'validate_argument_project_term_argument_action_top_with' => 'pass',
    'validate_argument_project_term_argument_action_child' => 'pass',
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'group_nid' => array(
    'operator' => 'or',
    'value' => array(
      '260' => '260',
      '261' => '261',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'group_nid',
    'table' => 'og_ancestry',
    'field' => 'group_nid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
    'reduce_duplicates' => 0,
  ),
  'is_public' => array(
    'operator' => '=',
    'value' => '0',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'is_public',
    'table' => 'og_ancestry',
    'field' => 'is_public',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('row_options', array(
  'inline' => array(),
  'separator' => '',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'groups/%/%/private');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

This works fine at the fully qualified url of example.com/groups/group1/events/private but it doesn't degrade nicely, That is, you can't do example.com/groups/group1/private and get private nodes of any content type. You have to use 'all' (ie example.com/groups/group1/all/private) or you get 'page not found'. The only way i found to get it to degrade properly is if the 'private' is moved to the front of the url (ie example.com/groups/private/group1/events).

nickbits’s picture

ludo1960, WorldFallz,

Thank you both for the help. I am not at my Dev machine at the moment so will have to leave it until Friday to test. Will get back to you and let you know how I get on. I do plan to document this properly when I get it all working. Not sure if it is me or not, but the way I expect/think things should work in OG just dosn't seem to be right. Probably just me not having my head in gear.

Thanks again.
Nick

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

nickbits’s picture

Hi,

Again thank you both for your help. I have been unable to get either method to work on my system. The last method dosn't work on my system with the code supplied. I am wondering if I have somehow corrupted my installation (will try a fresh install later). The first method - group_nid to group_path - just gave me errors on the views configuration itself. This seems the most logical to me, just cannot get it to work though.

Nick

------------oOo----------------------
Nick Young (www.nickbits.co.uk)

xgmorkx’s picture

To solve the same issue I tackled it with a view on path /projects/%/todos, added an "organic groups: groups" argument and used the following code as the php validator code for that argument:

$pos = stripos($_SERVER['REQUEST_URI'],"/projects/");
if($pos !== FALSE && $pos == 0){
   //ask path alias for this project, get original node, and get group from this node
   $pieces = explode("/",$_SERVER['REQUEST_URI']);
   if(count($pieces)==4){ //urls like /projects/foo/bar
      //pop the end off, and search for this alias
     array_pop($pieces);
     $node_path = drupal_lookup_path("source",substr(implode("/",$pieces),1)); //remove front slash too ;)
     $pos = stripos($node_path,"node/");
     if($pos !== FALSE && $pos == 0){  // ok, we found a node as response
        $handler->argument = substr($node_path,5); //substrings the /node and leaves us with an ID
        return true;
     }
   }
}
return false;

Although it works, something like a title parameter for groups would come in handy ;)