Hi,
I'm trying to fill up a gap in Users subscriptions management with Views, but cannot find a way:
My website have several newsletters and I would like to list in a table all registered users with their different newsletter subscriptions, as below.
John Doe Newsletter 3
Newsletter 5
Mark Zuck Newsletter 2
...
I thought this would not be difficult to achieve with Views, however, I could not find yet any way to get the proper relationships. If I start with a Users view, I'm getting only 'Simplenews subscriber: User' relationship. And if I start with a Simplenews subscriber view then the best that I can get is a list with Users and the Simplenews subscription: Term ID they are linked with (see attached copy screen and view export below).
Maybe I'm missing something. Does someone have a better way to list registered users subscriptions ? Thanks for any hint.
$view = new view();
$view->name = 'users_subscriptions';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'simplenews_subscriber';
$view->human_name = 'Users Subscriptions';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Users Subscriptions';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'name' => 'name',
'tid' => 'tid',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'name' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'tid' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* Relationship: Simplenews subscriber: User */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'simplenews_subscriber';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Relationship: Simplenews subscription: Subscriber ID */
$handler->display->display_options['relationships']['snid']['id'] = 'snid';
$handler->display->display_options['relationships']['snid']['table'] = 'simplenews_subscription';
$handler->display->display_options['relationships']['snid']['field'] = 'snid';
/* Relationship: Simplenews subscription: Term ID */
$handler->display->display_options['relationships']['tid']['id'] = 'tid';
$handler->display->display_options['relationships']['tid']['table'] = 'simplenews_subscription';
$handler->display->display_options['relationships']['tid']['field'] = 'tid';
/* Relationship: User: Profile */
$handler->display->display_options['relationships']['profile']['id'] = 'profile';
$handler->display->display_options['relationships']['profile']['table'] = 'users';
$handler->display->display_options['relationships']['profile']['field'] = 'profile';
$handler->display->display_options['relationships']['profile']['relationship'] = 'uid';
/* Relationship: Simplenews category: Term ID */
$handler->display->display_options['relationships']['tid_1']['id'] = 'tid_1';
$handler->display->display_options['relationships']['tid_1']['table'] = 'simplenews_category';
$handler->display->display_options['relationships']['tid_1']['field'] = 'tid';
$handler->display->display_options['relationships']['tid_1']['relationship'] = 'tid';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Field: Simplenews subscription: Term ID */
$handler->display->display_options['fields']['tid']['id'] = 'tid';
$handler->display->display_options['fields']['tid']['table'] = 'simplenews_subscription';
$handler->display->display_options['fields']['tid']['field'] = 'tid';
/* Filter criterion: User: Active */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'users';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['relationship'] = 'uid';
$handler->display->display_options['filters']['status']['value'] = '1';
$handler->display->display_options['filters']['status']['group'] = 1;
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'admin/people/simplenews/subscriptions';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'Users Subscriptions';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;
| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2013-05-07 at 10.12.14 PM.jpg | 64.84 KB | dan_metille |
Comments
Comment #1
jippie1948 commentedThanks for this suggestion. You provided me with a view that I could use to make 'membership' lists of subscribers to a particular newsletter.
Comment #2
portulacaI did it with Subscriber views, so basically simply continue editing the views you mention above.
Add the Relationship "Simplenews subscription: Term ID" (it will probably be labeled "Term (newsletter series)"). Then under Fields or Filters add "Taxonomy Term: Name" and it will probably already come with the Relationship "Term (newsletter series)" selected, because it won't work without it.
You will now see the category name appear in your views results, or the filter field (I exposed it) above the results.
The only thing that is bothering me is I can't get the exposed filter to display as a list, it only shows the textfield.
EDIT:
I was able to get the Exposed filter to display as a drop-down list instead of an autocomplete field by using the "Taxonomy term: Term" field that has this text in the description: "Taxonomy term chosen from autocomplete or select widget." and then choosing the "Dropdown" instead of "Autocomplete" in the filter settings.
Comment #3
ressaIn a related task, I needed to find users without a subscription, and ended up using Aggregation to count the number of subscriptions, and listed them at the top: