Date Range Availability
The Date Range Availability module allows you to manage and display availability for entities (e.g., events, products, resources) based on date ranges. It supports multiple availability states (e.g., Available, Unavailable, Coming Soon) and integrates with Drupal Views and custom theming.
Features
- Define availability based on date ranges.
- Supports states like Available, Unavailable, and Coming Soon.
- Views Integration: Add an Availability field to Views.
- Custom Theming: Use the
node_availability()
Twig function.
Installation
- Download and enable the module.
- Configure the date range field for your entities.
- Use the
node_availability()
function in templates or add the Availability field to Views.
Usage
In Templates
{% set state = node_availability(node.id(), 'field_date') %}
<div class="availability {{ state.label_class }}">
{{ state.label }}
</div>
```Views
To show the availability state in Views:
Add the Availability field to your View.
Configure the field by specifying the machine name of the date range field (e.g., field_date).
The availability state will be displayed for each row in the View.