Skip to content

Views: Query Alter

Plugin ID: eca_views:query_alter

Available since: 2.0.0

Provided tokens

Token Description
[user] The current user.
Alias: current_user
[htmx] Information about the current HTMX request.
[htmx:is_request] Whether the current request was sent by HTMX ("1" or "0").
[htmx:boosted] Whether the current request was boosted by HTMX ("1" or "0").
[htmx:history_restore] Whether the current request is for HTMX history restoration ("1" or "0").
[htmx:target] The identifier of the element the response is targeted at.
[htmx:trigger] The identifier of the element that triggered the request. On Drupal 11 this is the element id, on Drupal 12 and later it is the CSS selector that htmx 4 sends. Prefer "trigger_name", which means the same thing on both.
[htmx:trigger_name] The name attribute of the element that triggered the request, or empty if it has none. This has the same meaning on all supported Drupal versions.
[htmx:source] The CSS selector of the element that triggered the request, for example button[name="first_item"]. Empty on Drupal 11, which does not send this information.
[htmx:request_type] Whether the request targets a full page or a fragment: "full" or "partial". Empty on Drupal 11, which does not send this information.
[htmx:current_url] The URL of the page the request was sent from.
[event] The event.
[event:args:?] The list of arguments given to the view.
[event:display_id] The display_id of the view.
[event] The event.
[event:machine_name] The machine name of the ECA event.
[session_user] The user account that dispatched the event, regardless if ECA is processing models under a different account. This is only available if ECA is configured to always run under a specific account.

Fires during the build phase, after all handlers have added their conditions but before the query is finalized. This is the place to add extra WHERE conditions, JOINs, or modify sort orders dynamically.

Useful for row-level access control, dynamic filtering based on user context, or adding conditions beyond what Views handlers provide.

Fields

View — config key: view_id

Select the view from the list.

Type: select · Required: yes · Default: empty string

Allowed values depend on the configuration of the target site.

Value format: The machine name of a view on the target site.

Select the View this event should react to. Only enabled Views are listed.

Display — config key: display_id

Provide the view display id to which to respond. Leave empty to respond on any display.

Type: textfield · Required: no · Default: empty string

Value format: The machine name of a display within the selected view, for example default or page_1.

The machine name of a specific display (e.g., page_1, block_1). Leave empty to react to all displays of the selected View.