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
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

moshe weitzman - July 8, 2008 - 17:32
Status:active» by design

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

#2

dugh - July 8, 2008 - 20:53
Status:by design» 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.'),  
        ),

#3

bonobo - July 12, 2008 - 15:28

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

dugh - July 12, 2008 - 15:46

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

dugh - August 17, 2008 - 16:39
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

#6

najibx - September 19, 2008 - 02:25

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

mshaver - October 28, 2008 - 22:43
Version:5.x-7.3» HEAD

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

ciberligre - November 20, 2008 - 19:24

subscribe

#9

moshe weitzman - November 28, 2008 - 19:39
Status:reviewed & tested by the community» active

#10

samhassell - December 15, 2008 - 05:50

+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

dugh - January 4, 2009 - 17:48
Version:HEAD» 5.x-7.3
Status:active» needs review

#12

dugh - May 4, 2009 - 13:37
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.

#13

bonobo - May 4, 2009 - 16:01

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

sethcohn - June 16, 2009 - 03:31
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.

 
 

Drupal is a registered trademark of Dries Buytaert.