📜 ⬆️ ⬇️

Drupal 7 - Module for subscribing to new materials by email

Foreword

I know about the existence of modules SimpleNews, Notifications, etc. There are even instructions on how to do this with existing modules. It seems to me that there is too much to do in order to make the simplest email list available on the site. I decided to correct this situation a little. The module does not claim to originality and genius. I wanted to make the module easy to configure and use.

Email Subscribe module


Page with module settings:



Here you can configure the following parameters:

Page with the list of subscribed users:



Algorithm of the module


There is a table:
CREATE TABLE IF NOT EXISTS `email_subscribe_readed_nodes` ( `rn_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Field ID', `rn_nid` int(10) unsigned DEFAULT NULL COMMENT 'Node ID', `rn_sid` int(10) unsigned DEFAULT NULL COMMENT 'Subscribe user id', `rn_status` smallint(6) NOT NULL DEFAULT '0' COMMENT '0-email don't send, 1-email has been sented.', `datechange` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Date of change', PRIMARY KEY (`rn_id`), KEY `rn_nid` (`rn_nid`), KEY `rn_sid` (`rn_sid`), KEY `rn_status` (`rn_status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 


User interface


There is a block and a page with a subscription form. You can turn off the menu link because, it seems to me, the block is more convenient. The block is disabled by default. The user enters an email address and then there are several scenarios:

In all cases, the user is sent an email with a link to confirm the selected action.
')
Waiting for comments and suggestions.

The module is under BSD licenses. The source code on Github and in the sandbox on drupal.org .

UPD:
Fixed a small bug: for registered users, the default subscription form was their email, for anonymous users there was an error that the $ user object does not have a mail property.
UPD 2:
Fixed bug: in the form of subscription $ form ["# action"] was relative, not absolute (the slash was lost).
UPD 3:
Slightly changed the algorithm for filling the “email_subscribe_readed_nodes” table. Previously, only published materials were included; now, non-published ones with “Not read” status are also included.
UPD 4 dated 03/20/2015:
Updated to version 1.0.3.2.
UPD 5 of 03/26/2015:
Updated to version 1.0.3.3 .
UPD 5 from 12/24/2015:
Updated to version 1.0.4 .
UPD 6 of 12/12/2016:
Updated to version 1.0.5 .
UPD 7 dated 1/18/2017:
Updated to version 1.0.5.1 .

Source: https://habr.com/ru/post/208854/


All Articles