Skip to content

Drupal 8 module adds a filter validator that can evaluate a numerical filter value based on user-supplied constraints.

Notifications You must be signed in to change notification settings

CascadePublicMedia/contextual_filter_range_validator

Repository files navigation

Contextual Filter Range Validator

CONTENTS OF THIS FILE

  • Introduction
  • Requirements
  • Installation
  • Configuration
  • Use Cases
  • Maintainers
  • License

INTRODUCTION

Contextual Filter Range Validator adds a Views contextual filter validator that can evaluate a numeric filter value based on user-supplied constraints.

REQUIREMENTS

No special requirements.

INSTALLATION

  1. Download and uncompress the module manually or via Composer.
  2. Enable the module from /admin/modules.

CONFIGURATION

The module has no menu or modifiable settings. There is no configuration.

Range validation can be configured on any regular Views contextual filters. See USE CASES for a detailed example of how to assign validation criteria to a filter.

USE CASES

Display a view attachment on the first page of a view only.

The example steps below can be used to display a view attachment on the first page only:

  1. Create a page view with an attachment.
  2. Add a contextual filter to the attachment (Attachment -> Advanced -> Contextual Filters -> Add)
  3. From the "Add contextual filters" popup:
    • Select "This attachment (override)" from the For menu.
    • Select "Global" from the Category menu.
    • Enable the checkbox for the "Null" filter.
    • Click Apply (this display).
  4. Under When the filter value is NOT available, select Provide a default value and set the following options:
    • Type: Query parameter
    • Query parameter: page
    • Fallback value: 0
  5. Under When the filter value IS available or a default is provided, select Specify validation criteria and set the following options:
    • Validator: Range
    • Minimum value: (blank)
    • Maximum value: 0
    • Action to take if filter value does not validate: Hide view
  6. Click Apply (this display).
  7. Click Save for the full view.

Once this view is saved, the view page should only show the attachment on the first page because this module's validator is set to hide the attachment whenever the page URL parameter is not empty or zero (the first page/default value).

MAINTAINERS

Current maintainers:

This project is sponsored by:

LICENSE

All code in this repository is licensed GPLv2. A LICENSE file is not included in this repository per Drupal's module packing specifications.

See Licensing on Drupal.org.

About

Drupal 8 module adds a filter validator that can evaluate a numerical filter value based on user-supplied constraints.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages