I created a "like" flag on the nodes.

I created a view that displays the comments.

I want my view to show only comments posted since the flag date.

The solution will be to create a filter criteria with the filter "Comment: Publication date" (Is greater than or equal to) and replace the value with the date of the flag.

The problem is that there are no tokens for the filter criteria.

There is a tutorial here :


But I failed to create the criteria filter. This is the first time I've created code for a view.

Can you explain to me in an answer how to do this step by step ?

thank you in advance

I created a folder :


And a file notify_node_new_comment.yml that I placed inside :

name: Notify node new comment
description: Notification of new comments.
type: module
core: 8.x

I created an empty file notify_node_new_comment.views.ink in my folder (I do not know what to put as code).

I also added the following folders :


enter image description here

enter image description here

1 Answer 1


Views filters have nothing to do with tokens. What you need to do is build the necessary query for this, which is something that tutorial ignores completely as it is a pretty simple condition.

A bit of searching pointed me to \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTidDepth::query as an example that builds a complex subquery condition in a filter.

I don't know your level of expertise with PHP/Drupal/SQL, so I would recommend you start by building the SQL that is needed for this by hand. In the views settings, enable to show the SQL query on the preview. Then copy that query, remove the {/} execute it by hand and try to adjust it to contain the filter you need. You probably want to add a relationship to flaggging already.

Once you have that, implement that in PHP in the query method of your filter.

  • I do not know how to do that. I updated my question with the screenshot of my view.
    – user82735
    Commented Feb 11, 2018 at 22:30
  • I did not understand your answer it is complicated for me
    – user82735
    Commented Feb 12, 2018 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.