Select which group to filter view
dugh - July 8, 2008 - 17:05
| Project: | Organic groups |
| Version: | 5.x-8.x-dev |
| Component: | Og Views |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
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.

#1
thats a Views request for dropdown of node titles. not specific to OG
#2
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.'),
),
#3
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.
#4
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.
#5
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
#6
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.
#7
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.
#8
subscribe
#9
#10
+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?
#11
#12
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.
#13
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.
#14
open for a patch here if someone still wants this for D5 + Views 1.