0

I am new to Drupal and would love some guidance on how best to achieve the following:

An admin page that has (top-down):
- a date selector, defaulting to today's date
- a section displaying Arrivals for the date selected (this selects custom content type 'Bookings' with filter of arrivalDate = dateselected)
- a section displaying Departures for the date selected (this selects custom content type 'Bookings' with filter of departureDate = dateselected)

I'm interested in how conceptually an experienced Drupal developer would approach this with Views.
Note: The project uses Drupal 7.

My approach so far:

  1. One view with Page display that lists the Arrivals and uses an Exposed Filter for the date
  2. One view with block display that lists the Departures and uses a hidden filter for the date
  3. The block display (2) is shown in the Footer of page display (1)
  4. The mymodule_views_pre_build hook is used to set the exposed filter date in (1) and hidden filter date in (2)

The initial load of Page (1) is working fine. Changing the date via the Exposed Filter in (1) correctly updates the Arrivals list; but not the Departures. I'll need to update the hidden filter in (2) somehow.

1 Answer 1

0

The described scenario doesn't need custom coding as it is shipped with Drupal 7 Views module.

The approach to use a views block in a views page that shares the same filter can be done using the "Attachment" view.

You can find more about views attachment here

Also, there is an answer to place the attachment in a different page region here

Hope this answers your question.

2
  • Thanks for your prompt response. I've now tried an attachment. However in this scenario it isn't really the same filter. The Arrivals display filters on field arrivalDate, the Departures display filters on field departureDate. The dateselected is the same across both but the filtering field is different. So I can't see inherited filters working. Am I misunderstanding something? Commented Aug 15, 2019 at 17:58
  • Thanks again. Your attachment suggestion worked well and keeps things better organized. On the attachment I replaced the exposed filter from the Page display (1) with a Global: PHP filter and used the filter variable from the $_GET scope. Commented Aug 15, 2019 at 21:11

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.