It would be nice to have a select (selector/listbox) control filter for views that could let people filter calendar events for example by selecting an existing group, rather than having to type in a group name or remember a group ID number.

Comments

moshe weitzman’s picture

Status: Active » Closed (works as designed)

thats a Views request for dropdown of node titles. not specific to OG

dugh’s picture

Status: Closed (works as designed) » Needs review

Views already has this feature, and you are already using it for other og filters.

Here's the code to actually do what I was requesting. Modify if you wish to prevent private groups from being listed in the listbox, but I prefer it this way. If someone selects to see nodes from a group to which they don't belong, they just get an empty list (or calendar).

I added it to og_views.inc around line 157:

        'group_name' => array(
          'name' => t('OG: Select Group'),
          'list' => og_all_groups_options,
          'list-type' => 'list',
          'operator' => 'views_handler_operator_or',
	  'value-type' => 'array',
	  'field' => 'group_nid',
          'help' => t('Filter for posts in specified organic groups using a dropdown list of group names. Use as an exposed filter.'),   
        ),
bonobo’s picture

Rather than modifying core OG code (or really, any core code, which will get unsustainable over time) set a views header that lists all the groups you want to expose. Then, pass the nid of the group to a view as an argument. This assumes, of course, that you have set your view to accept group nids as arguments.

dugh’s picture

Yes it is unsustainable to keep having to add this code to your own copy of the module, which is why I posted this feature request.

dugh’s picture

Status: Needs review » Reviewed & tested by the community

I'm already using this in views all over our website, it works fine.
http://itls.usu.edu/calendar
http://itls.usu.edu/calendar/upcoming
http://itls.usu.edu/trackchanges
and others

najibx’s picture

cool. the above hack to og_views.inc, would list down all groups isn't?
I am not clear about comment#3.

We put an HTML select list form of only selected group we want to list down in the views' header section? and of course as you said set view to accept group nids as arguments.

mshaver’s picture

Version: 5.x-7.3 » master

It would be great to get something similar added to Drupal 6.x and Views2. It would involve creating a new handler and doing things in the new Views2 api way, which I'm not quite familiar with yet.

esclapes’s picture

subscribe

moshe weitzman’s picture

Status: Reviewed & tested by the community » Active
samhassell’s picture

+1, seems to be a basic view compared to some of the stuff already supplied by og.

in #3, did bonobo mean a views handler, instead of a views header?

dugh’s picture

Version: master » 5.x-7.3
Status: Active » Needs review
dugh’s picture

Status: Needs review » Reviewed & tested by the community

No, bonobo meant you manually type in links to all the group names in the header of a view. Our site we get new groups all the time - I don't want to have to manually edit the view header each time a new group is made.

I'm about to upgrade our site to drupal 6, I'll see what changes to that snippet of code are necessary to make it work in drupal 6.

bonobo’s picture

Actually, while it could be done by manually typing in links in the views header, we usually do it as a php snippet that outputs the list. Then, we pass the "right" argument to the view.

Then, depending on how the site is being used, we break that code out into a site-specific module; ie, a yoursite.module that contains the site-specific modifications.

And with all that said, I suspect that between Views and OG in D6 that this will be a lot easier -- Given that you can set the terms included in filters for views this might Just Work in D6.

sethcohn’s picture

Version: 5.x-7.3 » 5.x-8.x-dev
Component: og.module » Og Views
Status: Reviewed & tested by the community » Needs work

open for a patch here if someone still wants this for D5 + Views 1.

najibx’s picture

while this exposing listing of groups for views, how about listing og groups when adding/editing node? ie. refering to another group for certain node?

dugh’s picture

Status: Needs work » Closed (fixed)

There is built-in support for this in the drupal 6 version of OG and Views 2, so I'm closing this.