0

I'm throwing a big number of views showing a list of 'events' (nodes) happening today, tomorrow and after tomorrow. I'd like registered users with role 'editor' could see all events from today (not only until after tomorrow).

Ideally it would be something like this:

  • if user (visitor) == editor -> filter: date >= today
  • else filter: date >= today && date <= +2 days

In other words:

  • filter: date >= today
  • if user (visitor) != editor -> filter (AND): date <= +2 days

The idea is to be able to add some filters depending on the visitors role (not the node creator one).

Is it possible making use of default views panel?

Otherwise I'd have to duplicate + modify filter + modify permissions + add in block design list some dozens! of blocks.

8
  • I post it first as a comment. Then if no better solution is suggested I'll post it as the answer to my own question. One way to 'solve' i would be to set the view with the most generic query (only filter: date >= today) and then shorten the offer of 'events' (nodes) shown via conditional twig in the own theme template file. I only can see 2 cons to it: 1. not all the control is in the own views panel 2. depending on use of cache processing the webpage will take longer as the query in the view will ask in all cases for the broadest list of results
    – hip
    Sep 20 at 8:31
  • 1
    I would add a contextual filter for the date field and then provide the filter limits as arguments. If you don't render the Views yourself use hook_views_pre_view.
    – 4uk4
    Sep 20 at 13:27
  • Instead of having a custom solution, did you consider managing it from the views UI? You clone your view and have different configs to the filter, then assign permissions to each view. I think this is easier to maintain. Sep 20 at 15:07
  • @HodbaKhalaf Ty but as mentioned it is a large number of views/blocks and it would suppose a massive number of extra blocks that specially in the list of block placements would be very hard to keep.
    – hip
    Sep 21 at 13:16
  • @4uk4 Ty! Not sure how to proceed with it but I'll give it a look
    – hip
    Sep 21 at 13:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.