This project is not covered by Drupal’s security advisory policy.

Views Browser Storage uses existing localStorage or sessionStorage values for Views contextual filters and entity relationships. Read a storage key directly or extract a nested JSON value using a path such as bar.foo.key.

The module reads values when a View loads or refreshes through AJAX. It does not write to browser storage or provide a selection interface.

Logo

Features

  • Contextual filters: Filter content using a stored value, with an optional fallback when unavailable.
  • Entity relationships: Use a stored entity ID to access related fields, filters, and sorting options.
  • Nested JSON paths: Select properties with bar.foo.key or array items with bar.items.0.id. Only the selected value is sent to Drupal.
  • Flexible storage: Choose local or session storage and a separate key or path for each filter or relationship.
  • AJAX updates: Read current values during paging, sorting, exposed filtering, and explicit refreshes.

Post-Installation

  1. Enable Views Browser Storage and Views UI.
  2. Edit a page or block View and enable Advanced → Use AJAX.
  3. Add a contextual filter. Under When the filter value is NOT available, choose Provide default value → Browser storage (local/session).
  4. Choose the storage type, enter a Storage key or path, and optionally set a fallback. Set validation failures to Display contents of "No results found".
  5. Save and test on the actual page; the Views UI preview cannot read browser storage.

For example, configure bar.foo.key with local storage, then populate it through your site's JavaScript:

localStorage.setItem('bar', JSON.stringify({foo: {key: 12}}));
window.dispatchEvent(new Event('views-browser-storage:refresh'));

The View receives 12. Replace it with a suitable value for your filter or relationship. Use sessionStorage for session storage, and dispatch the refresh event after changes in the current tab.

For relationships, add Global: Browser storage: Taxonomy term or another entity type under Relationships. Every result row relates to the same selected entity; use a contextual filter to restrict which content appears.

Similar projects

  • Views Extras provides additional contextual filter defaults, including PHP sessions and cookies.
  • Views Global Filter shares filter selections across Views.

Important considerations

  • Path handling: An exact storage key takes precedence over a nested path. Missing paths, invalid JSON, null, objects, and arrays use the existing fallback or missing-value behavior.
  • Initial rendering: The first request uses the fallback or missing-value behavior before JavaScript refreshes the View. For blocks, leave Hide block if the view output is empty disabled.
  • Caching and access: Affected Views disable result, output, and render caching. Keep normal access, publication, and validation settings: browser storage is visitor-controlled input.
  • Scope: Supports SQL-based content entity Views. Search API, feeds, REST exports, and nested attachment displays are not supported.
AttachmentSize
views-browser-storage-logo.png516.72 KB

Project information

  • Created by eleonel on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases