A Drupal module that provides a dynamic special alerts feed block for Howard University websites. This module fetches real-time alerts from thedig.howard.edu and displays them as dismissible notification bars across your site.
- Features
- Quick Start
- Documentation
- Requirements
- Installation
- Configuration
- Usage
- API Reference
- Styling
- Troubleshooting
- Contributing
- License
- Real-time Alerts: Automatically fetches current alerts from thedig.howard.edu
- Date-based Filtering: Only displays alerts that are currently active based on start/end dates
- Dismissible Alerts: Users can dismiss alerts, with preferences stored in cookies
- Responsive Design: Mobile-friendly alert display with responsive padding
- Alert Levels: Supports different alert severity levels (low, high) with distinct styling
- CORS Support: Handles cross-origin requests securely
- Automatic Refresh: Loads fresh alert data on each page load
- Accessibility: Screen reader friendly with proper ARIA labels
-
Install the module:
composer require howard/howard_special_alerts_feed drush en howard_special_alerts_feed
-
Place the block:
- Go to Structure > Block Layout
- Find "Howard Special Alerts Feed" block
- Place it in your desired region
-
Verify it's working:
- Visit your site's frontend
- Check for alerts in the configured region
- Test dismissal functionality
This README provides an overview and basic usage information. For comprehensive documentation, see:
- Installation Guide - Detailed installation instructions and troubleshooting
- API Documentation - Complete JavaScript and PHP API reference
- Developer Guide - Development setup, customization, and contribution guidelines
- Changelog - Version history and upgrade notes
- Need help installing? → Installation Guide
- Want to customize? → Developer Guide
- Looking for API details? → API Documentation
- Upgrading? → Changelog
This module requires the following:
- Drupal Core: 10.x or 11.x
- Modules:
block
(core module)
- PHP: 7.4 or higher
- Network: Outbound HTTPS connections to thedig.howard.edu
- CORS: Properly configured CORS headers on thedig.howard.edu
- JavaScript: Modern JavaScript support (ES6+)
- APIs: Fetch API support
- Cookies: Cookie support for dismissal functionality
composer require howard/howard_special_alerts_feed
- Download the module and place it in your
modules/custom/
directory - Enable the module via Drupal admin interface or Drush:
drush en howard_special_alerts_feed
-
Clear caches:
drush cr
-
Configure block permissions if needed
- Navigate to Structure » Block Layout (
/admin/structure/block
) - Find the "Howard Special Alerts Feed" block
- Click "Place block" in your desired region
- Configure block settings:
- Visibility: Set page, role, or other visibility conditions
- Region: Choose where the block appears (typically header or content)
The block provides informational text and links to help documentation. No additional configuration is typically required as the module automatically:
- Fetches alerts from thedig.howard.edu
- Filters by current date
- Handles dismissal via cookies
The module is configured to fetch alerts from:
https://thedig.howard.edu/jsonapi/node/alert
With automatic filtering parameters for:
- Start date ≤ current date
- End date ≥ current date
- Status = published
Once installed and configured, the module automatically:
- Fetches Alerts: On page load, queries thedig.howard.edu for active alerts
- Displays Alerts: Renders alerts as notification bars
- Handles Dismissal: Allows users to dismiss alerts individually
- Manages Visibility: Hides dismissed alerts using cookies
Each alert includes:
- Title: Main alert message
- Subtitle: Additional details (optional)
- Link: Either to the full alert page or custom URL
- Level: Alert severity (low, high)
- Dates: Start and end dates for visibility
- Viewing: Alerts appear as prominent notification bars
- Dismissing: Click the X button to dismiss an alert
- Persistence: Dismissed alerts remain hidden until cookies expire
The module provides both JavaScript and PHP APIs for advanced customization.
The module exposes a specialAlertsFeed
object with methods for:
loadEventData()
- Fetches alert data from thedig.howard.educheckAlerts(data, site)
- Processes and filters alert datasetAlertBars(data)
- Renders alerts to the pagehideAlerts()
- Hides alerts when none are activesetDismiss()
- Handles alert dismissalsetCookie(key, value, days)
- Stores dismissal preferencesgetCookie(key)
- Retrieves dismissal preferences
The module integrates with Drupal through:
- Block Plugin:
SpecialAlertsFeedBlock
class - Hooks:
hook_help()
andhook_theme()
- Libraries: CSS and JavaScript asset management
For detailed API documentation including parameters, return values, and examples, see the API Documentation.
The module provides the following CSS classes for styling:
.alerts-feed-wrapper
: Main container for all alerts.alerts-active
: Added to body when alerts are present.no-alerts
: Added to body when no alerts are active
.newsroom-alert
: Individual alert link.newsroom-alert--low
: Low severity alert.newsroom-alert--high
: High severity alert.newsroom-alert-dismiss
: Dismiss button
.hidden
: Applied to dismissed alerts
The module includes responsive breakpoints:
- Mobile (1px - 1000px): Adjusted padding for smaller screens
- Tablet (1000px - 1700px): Percentage-based padding
- Desktop (1700px+): Maximum padding for large screens
To customize alert styling:
- Override CSS: Add custom styles to your theme
- Template Override: Copy the Twig template to your theme
- JavaScript Extension: Extend the JavaScript object for custom behavior
Example CSS customization:
/* Custom alert colors */
.alerts-feed-wrapper .newsroom-alert--low {
background: #your-color;
}
.alerts-feed-wrapper .newsroom-alert--high {
background: #your-urgent-color;
}
-
Check Network: Verify your server can reach thedig.howard.edu
curl -I https://thedig.howard.edu/jsonapi/node/alert
-
CORS Issues: Ensure CORS headers are properly configured on thedig.howard.edu
-
JavaScript Errors: Check browser console for JavaScript errors
-
Block Placement: Verify the block is placed in a visible region
- Cookie Settings: Check if cookies are enabled in the browser
- JavaScript Errors: Verify no JavaScript errors are preventing execution
- Event Handlers: Ensure click handlers are properly attached
For comprehensive troubleshooting including:
- Detailed diagnostic steps
- Common installation issues
- Performance optimization
- Debug mode instructions
- Server configuration problems
See the Installation Guide for complete troubleshooting documentation.
We welcome contributions to the Howard Special Alerts Feed module!
- Fork the repository on GitHub
- Create a feature branch from the main branch
- Make your changes following our coding standards
- Test thoroughly across different browsers and devices
- Submit a pull request with a clear description
- Follow Drupal coding standards
- Add tests for new functionality
- Update documentation for changes
- Ensure backward compatibility
For comprehensive development information including:
- Development Environment Setup
- Module Architecture
- Coding Standards
- Testing Strategies
- Customization Examples
- Performance Optimization
- Security Best Practices
See the Developer Guide for complete development documentation.
When reporting issues, please include:
- Drupal version and module version
- Browser and version
- Steps to reproduce
- Expected vs actual behavior
- Any error messages or screenshots
Submit issues on GitHub Issues.
- Issues: GitHub Issues
- Source: GitHub Repository
- Maintainer: Dan Rogers
- Documentation: Complete Documentation - See the docs folder for comprehensive guides
- Comprehensive documentation suite with organized docs/ folder
- Enhanced JavaScript and CSS documentation following Drupal standards
- Improved code structure and error handling
- Added coding standards document and developer guides
For complete version history, upgrade notes, and migration information, see the Changelog.
This project is licensed under the GPL-2.0+ License - see the LICENSE file for details.