Table of Contents

Drupal Module

cha_enews: https://github.com/ginkgostreet/cha_enews/

Builds the form and other markup.

Create a drupal block

Declares a drupal block with cha_enews_block_info() in file cha_enews.module.

Declares a callback for supplying content to our custom block: _cha_enews_block_content_subscribe()

Template Override for the Block

  • templates/block--cha-enews.tpl.php Block template invoked through hook, cha_enews_theme() of cha_enews.module file.

Handle Form Submit

  • /js/enews.js

Uses CiviCRM's jQuery object CRM, and the jQuery Validate plugin:

  • submitHandler
  • blocks the form with a loading message
  • CRM.api3('MailingEventSubscribe'...)
  • display errors to user
  • after a time-out, resets the form display (clears the messages).

Updated: 3-27-2019