Score: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.

โพสต์คำตอบ

คนส่วนใหญ่ไม่เข้าใจว่าการถามคำถามมากมายจะปลดล็อกการเรียนรู้และปรับปรุงความสัมพันธ์ระหว่างบุคคล ตัวอย่างเช่น ในการศึกษาของ Alison แม้ว่าผู้คนจะจำได้อย่างแม่นยำว่ามีคำถามกี่ข้อที่ถูกถามในการสนทนา แต่พวกเขาไม่เข้าใจความเชื่อมโยงระหว่างคำถามและความชอบ จากการศึกษาทั้ง 4 เรื่องที่ผู้เข้าร่วมมีส่วนร่วมในการสนทนาด้วยตนเองหรืออ่านบันทึกการสนทนาของผู้อื่น ผู้คนมักไม่ตระหนักว่าการถามคำถามจะมีอิทธิพลหรือมีอิทธิพลต่อระดับมิตรภาพระหว่างผู้สนทนา