Sharing Engine/Drupal code: a module, a feature and a theme

From TransitionWiki
Jump to: navigation, search

There are 3 parts to the Drupal infrastructure for the Project Sharing Widget: 1. A custom 'Transition PSE' module that handles most of the business logic and form/widget generations features. 2. A Drupal Feature called 'Transition PSE Widget' consisting exported views, rules, roles, Panels displays and other variable settings 3. A custom theme called 'PSE' that provides a lightweight styling for the entry widget (not 'view' widget).


These are described below...

Custom module: Transition PSE

Author Jim Kirkpatrick, code available in the transition_pse GitHub repository.

This module handles most of the business logic and form/widget generations features. NOTE that this module is dependent on several other modules AND a the 'Transition PSE Widget' feature. Due to the specific requirements of the Transition Network site and existing module and information architecture, it was necessary to build a custom module to handle much of the generation, moderation, submission and display of the widget.

Features of the Transition PSE module

Generation & rendering the Widget

  • Allow users to get the widget, customising it to the type and initiative they want to use.
  • Renders a widget and related views via theme() functions.
  • Provides CSS and JavaScript (jQuery) code that the widget downloads into a host site's page for standard display (not entry or view of projects -- see PSE Theme below).

Submission entry workflow

  • Provide a form for a widget user to submit their project into.
  • Mapping code between the simplified form and a 'PSE Submission' content type.
  • Overrides the behaviour of Drupal's Project user registration form when shown in the widget.

Moderation

  • Moderation (accept/reject) menu callbacks.
  • Sends some/most user (submitter and widget owner/moderator) reminders and progress emails.
  • Mapping code between the accepted submission and a finished first-class 'Project Profile' in the project directory.

Other features

  • Automatically changes the theme to 'pse' for the 'view' and 'entry' type pages (see Sharing_Engine/Technical_Proposal#URL_structure.
  • Checks participant ID is registered and allowed to submit Projects though widget.
  • An .install file to ensure module weight is very heavy so its form alterations happen after all others

Dependencies on contributed modules

You should check out the module's .info file for more.

  • CCK -- Drupal 6 needs this to manage fields and content types properly.
  • jQuery Update -- Brings Drupal 6's ancient jQuery library up to date
  • MaxLength -- Puts a counter on for maximum number of characters on certain fields.
  • MailChimp -- Allows tight newsletter signup integration with MailChimp.
  • QuickTabs -- Allows content/html/views etc to be loaded via AJAX-enabled into a tabbed display very easily.
  • Views -- Allows data and content to be displayed and related in a number of ways.
  • Web Widgets -- Provides easy widget management and generation (only using part of this module's capabilities).

Feature: Transition PSE Widget

Author Jim Kirkpatrick, code available in the transition_pse_widget GitHub repository.

Drupal's Features module allows configuration that is otherwise stored in the database to be exported to the codebase and put into version control. This feature provides key rules, views, displays and variables needed for the operation of the Project Widget. The code is auto-generated by the Features module when the feature is updated.

Contents

  • Content type: project_pse = "PSE Project Submission" which contains the bare minimum fields and references needed to keep a submission as quick as possible.
  • Page manager view: A node view for above content type.
  • Rules of category "PSE": Sending emails and setting roles mainly
  • Role: "Widget Owner" - basic admin capabilities (with perms 'get widget code' and 'view submissions in moderation' set)
  • Role: "Widget User" - for users tracking who registered via widget
  • Strongarm: Settings for project_pse content type, path aliases etc
  • View: transition_pse_projects_admin ('site administrator' views) - lists all submissions
  • View: transition_pse_widget ('widget owner' views) - lists submissions for user, shows accepted projects

Dependencies on other modules

Please view the feature's .info file for the full list, but below are the key dependencies.

  • Standard stuff for features: Content (CCK including Node & User References), CTools, Features, Strongarm, Token, User, Views
  • Location -- Provides location fields for the Project Submission content type.
  • Page manager and Panels for a custom node layout for the Project Submission content type.
  • Rules -- used for assigning some roles and sending emails during certain events.
  • Transition PSE -- custom module, see section above.
  • Views Bulk Operations -- @todo VBO is now not needed and can be removed


Custom theme: PSE

Author Laura Whitehead, code available in the pse GitHub repository.

A responsive theme that shows form elements and views of projects cleanly. Also has code to strip out most of the standard Drupal and contrib CSS to keep the downloaded code clean.