My Favourites , Click on/Click off heart icon

Created on 3 April 2025, 6 days ago

Problem/Motivation

Adds UI blocks, dynamic rendering, and optional backend storage for managing anonymous and authenticated favourites.

Introduced a "My Favourites" block that dynamically displays selected content using JavaScript and AJAX.

Added a "Heart Icon" block for node pages, enabling users to toggle favourites via a visual and keyboard-accessible control.

  • Implemented support for anonymous users using cookie-based storage, with a configurable expiration.
  • Added a setting to toggle between cookie storage (for anonymous users) and database storage (per user uid for authenticated users).
  • Created an AJAX controller that returns published node titles from stored favourites, with revision-safe querying.
  • All frontend logic uses modern Drupal.behaviors and once() pattern, fully compatible with Drupal 10.4+ and 11.x.
  • Code gracefully handles both revisionable and non-revisionable content types.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada joseph.olstad

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024