This project is not covered by Drupal’s security advisory policy.
Provides an API that allows you to take actions when new content is added, either immediately or in a digest format.
Use Case
Lets say you have a node type 'article' with a field 'field_article_type'. It is a text list field with three options (news, blog, press_release). This module allows you to create an hourly/daily/weekly subscription of article nodes with a field values of "news".
Here is the way it works:
- A subscription is considered to be for new content of any entity type.
- A subscription can be filtered based on multiple field values.
- Subscription sending is set on a per user basis.
The process leverages Drupal's Queue API, to process all of the subscription checking/sending, so cron must be set to run on a regular basis. I would highly recommend Elysia Cron to manage the cron/queue.
This module currently has no UI, therefore you will need either another module, or a custom interface for adding subscriptions.
The way to add a subscription is as follows. Using the example above:
$fields = array(
'field_article_type' => 'news',
);
field_based_subscriptions_subscribe($account, 'node', 'articles', 'weekly', $fields);
You can add as many field "filters" as you need.
This module also does NOT send emails. It generates the list of items to be sent, and then requires another module to do the actual sending. A hook provides the ability to grab the account, and the list of items to be sent.
Here is an example of what could be done:
/**
* Implements hook_field_based_subscriptions_send().
*/
function mymodule_field_based_subscriptions_send($account, $items) {
$item_list = array();
foreach($items as $item){
$load = entity_load($item->entity_type, array($item->entity_id));
$loaded = array_shift($load);
$item_list[] = l($loaded->title, 'node/' . $loaded->nid,array('absolute' => TRUE));
}
$list = theme('item_list', array('items' => $item_list));
$mail = $account->mail;
$message = 'Here are some new items:';
$message .= $list;
// call some function to actually send an email.
}
Project information
- Project categories: Content editing experience, Site structure, Integrations
- Created by chertzog on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
