Рейтинг:0

Listing articles that matches a specific set of filter criteria

флаг kz

I have a Drupal 9 site with three roles: Editor, Reviewer and Author.

I use the core Article content type, with one additional field: field_reviewer. It is an Entity Relation to the user that has been assigned the task of reviwing the Article.

Articles may be created by Editors (typically from an article submitted by an external Author), or by an Author that is already a user. Editors has full access to all Articles, and may assign a Reviewer to any Article in the system.

I want to show all roles a list that is called "MyArticles". This list should have the following filter criteria:

  1. Content type: Article; AND
  2. Have a Reviewer assigned; AND
  3. ( Be authored by the currently logged in user; OR
  4. The currently logged in user is the Reviewer. )

I've tried to create a View with these filter criteria, and have no problem creating a View that matches the two first criteria.

As for the third and fourth, I can:

  1. Create a View that is authored by the currently logged in user (using a relation).
  2. Create a View where the currently logged in user is the Reviwer (using a contextual filter).

But I am unable to make a View that combine the two. By default, it looks like a contextual filter by default uses an AND relation, so adding it excludes all nodes authored by the currently logged in user from the View.

I've tried to use the contribute module "Views Contextual Filters OR" https://www.drupal.org/project/views_contextual_filters_or

but I can't get it to work. It may have something to do with this bug report: https://www.drupal.org/project/views_contextual_filters_or/issues/3215441

Is generating the "MyArticles" list described above doable with Views?

If not, I am prepared to create a custom module for generating this list. I think I already know how to set up a dynamic SQL query for this in PHP, but what is the correct directory to place this PHP code. Will this be a "Controller", a "Form", a "Plugin", or something else?

PS: I know this can be resolved (sort of) by using the Workflow module, but I have other requirements (not mentioned in this question) that precludes use of the Workflow module for this, so I need to do it using Views or a custom module.

Ответить или комментировать

Большинство людей не понимают, что склонность к познанию нового открывает путь к обучению и улучшает межличностные связи. В исследованиях Элисон, например, хотя люди могли точно вспомнить, сколько вопросов было задано в их разговорах, они не чувствовали интуитивно связи между вопросами и симпатиями. В четырех исследованиях, в которых участники сами участвовали в разговорах или читали стенограммы чужих разговоров, люди, как правило, не осознавали, что задаваемый вопрос повлияет — или повлиял — на уровень дружбы между собеседниками.