9 – How to add filter criteria by current date in views

I am using Drupal 9 and have a content type with a field “Publish until” (datetime).
I want to add a filter in views that it will compare the date in this field with current date.
I found a solution here for Drupal 8
Views filter criteria date field is greater than current date

However, my screen looks a bit different:
enter image description here

To be more specific, I don’t have a “Value type” which seems to be necessary in my case.
Am I missing any module that should be enabled?
Or is it related to the Drupal 9 itself?

If there is any another approach to solve this problem with filtering I will be glad to know it.

views – Contextual Filter Path Alias

I searched for this for some time now but couldnt find an anwser. I am using drupal 9.1.5 and pathauto. I have content types department and depratment news. The news are linked to the department. So whenever you create a department news you link it to a department. Now I want to display all depratment news linked to the department when i am on the department page (all children) and when I am on a page of a children (department news) I want to display all siblings, i.e. all departments news linked with the same department.

My url for departments is
(node:title)
and for department news is
(node:field_department:entity)/(node:title)

I thought that using a contextual filter in my view using the raw value from the url would work. So I used path component 1 and checked to use path alias. However this does not display anything.
enter image description here

When using path component 2 and disable to use path alias it works for the department news, which makes sence as I am internally on page node/xxx. I was so frustrated that I tried every other combination of path component and use path alias but nothing works. When using a fixed value for a department everything works as expected for that specific department

webforms – Filter Views With Tokens on Computed Token Fields

I want to add a filter criteria on my view with a token (ex: (webform_submission: user: name)) on a “Computed Token Field” of my webform.
To display the data of my Webform in my view I use the Webform Views Integration module.

I tried by various means to solve my problem:

  • Use the Token Filter module, the Use Token option does not appear for data from Webform (Webforms Integration Views)

  • Use the contextual filter using the Views Extra module, on this side we have access to the data of the Webform, but the data which comes from type “Computed Token” or “Computed Twig” is not available to make the filter

Can someone help me solve my problem please?

web app – How to best place a “Filter” sheet in a webpage?

Consider the following page screen, that consists all conversations (left side) and the selected conversation display (middle of the screen; chat):

enter image description here

Now I would like to be able to filter the list of the conversations (that’s found on the left) by various options such as “Filter by classes” (there can be many of them), “New messages”, “Read but unanswered messages”, “Has Video, Has Files?” etc. But where would be the best place to put this filter sheet? The filter icon is already placed in at the top of the conversations that would enable the filter page.

I have outlined 4 possible options, however all have both good and bad sides:

enter image description here

A – Makes sense as it looks/feels like is filtering in the actual inbox. However, it hides the actual inbox, making it a bit unintuitive to see what you’re filtering for. Having a checkmark icon to confirm the filter would be a solution.

B – Material guidelines suggest to do it this way, to separate it form the navigation drawer on the left. However, in this chat looking design it looks more as if the Filter is related to the specific conversation, not total inbox.

C – okayish I suppose. We’re trying to avoid pop-ups if possible. But maybe it is a viable solution

D – Dropdown list next to the icon. This one’s tougher as it can’t be too large, but can provide difficulties when more options for filtering arise in the future.

What would you suggest? Perhaps another way completely?

commerce – Setting exposed filter default value from query string

I have a view which show products and an exposed filter block (category, manufacturer, price).

I want to set category default value from URL, like this:

/browse-products/category-id

though, I wrote this module which take the parameter from URL and put it into exposed filter default value.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  global $request;

  if ($form_id == 'views_exposed_form') {
    $category_id = (int)($request->attributes->get('_raw_variables')->get('arg_0'));
    $form('category_id')('#default_value')($category_id) = $category_id;
    dpm($form('category_id'));
  }
}

dpm output for /browse-products/5

Array
    (
        (#type) => checkboxes
        (#multiple) => 1
        (#options) => Array
            (
                (5) => Tablets
                (10) => -Ainovo
                (7) => -Galaxy Tab
                (6) => -IPad
                (1) => Smart Phones
                (4) => -Galaxy
                (3) => -IPhone
                (9) => --IPhone C
                (8) => --IPhone X
            )

        (#size) => 9
        (#default_value) => Array
            (
                (5) => 5
            )

        (#bef_nested) => 1
        (#theme) => bef_checkboxes
    )

but it doesn’t work?

another thing, why dpm($form) prints the views exposed form data twice!

update 1: I tried something like this (but didn’t work):

function mymodule_views_pre_build(DrupalviewsViewExecutable $view) {
    $view_filters = $view->display_handler->getOption('filters');
    $view_filters('field_category_target_id')('value')(8) = 8;
    $view->display_handler->setOption('filters', $view_filters);
}

or this:

function mymodule_views_pre_build(DrupalviewsViewExecutable $view) {
  $filters = $view->getExposedInput();
  $filters('field_category_target_id') = 8;
  $view->setExposedInput($filters);
}

javascript – Filter lists with HTML-form

Today i use HTML-Form web part to connect to the list in question. I then use the following code to filter/sort:

<div onkeydown="javascript:if (event.keyCode == 13) _SFSUBMIT_">
<select name="filter">
<option value="">Pick one</option>
<option value="Department 1">Department 1</option>
<option value="Department 2">Department 2</option>
<option value="Department 3">Department 3</option>
<option value="Department 4">Department 4</option>
<input type="button" value="show" onclick="javascript:_SFSUBMIT_"/>
</select>
</div>

When users are filtering the lists, it requires 3 clicks from them.
First, open the dropdown list, then select a value and finally, click on the “show”-button.

I want to reduce the number of clicks to one. by using buttons instead. It is possible? Or is the connection between web part and list the only way for this to work?