2

I'm trying to display the View according to the current director, example:

  • I have a content type called faculty news,and I have two faculties: Medicine and Sciences, the content type faculty news is all news of medicine and Sciences.

  • I have two administrators: admin-medicine and admin-sciences, each one has permissions to publish, read and write only in his faculty.

  • I have the View: Administrator faculty news with the path http://example.com/administrator-faculty-news

This view display nodes from content type faculty news.

Now I want to enhance this view like so: when the admin-sciences administrator uses the path http://example.com/administrator-faculty-news, then only the news of the Sciences faculty should be shown in the Views results, and the same for admin-medicine (only show the news of the Medicine faculty).

With contextual filter? How can I do that?

Note: Medicine and Sciences is implemented using taxonomy.

3

1 Answer 1

1

Contextual filters

I suggest you review the (free) video about Contextual filters with paths. It covers topics such as:

  • Using contextual filters for filtering Views result.
  • Using input from the view path to set contextual filter values.
  • Using contextual filter values for changing the view title.

If you like its content, you may also want to watch about 5 subsequent videos, also related to contextual filters (sometimes called "arguments" also).

Content Access

Even though your question is specific to Views, it seems like you should give it a thought to also get the Content Access module involved in your setup. Here is a quote from its project page:

This module allows you to manage permissions for content types by role and author. It allows you to specify custom view, edit and delete permissions for each content type. Optionally you can enable per content access settings, so you can customize the access for each content node.

Just use this module to give appropriate access to each of the groups of users for each of the content types you have. After you do, the view you currently already have will probably not need any (or just a few) refinements. Because Content Access (if configured correctly) will make sure that the view results only include the news from each faculty.

Bonus: you'll find other use-cases for this module soon!

Organic Groups

Organic Groups is possibly an alternative also, which provides 'Groups' for Drupal users, and management of Access Control based on these groups.

In your case, each faculty would probably correspond to 1 such "group". And similar to using Content Access, the view you currently already have will probably not need any (or just a few) refinements.

Bonus: you'll find other use-cases for this module soon!

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.