[support] Views filter rooms by occupacy

Jamie Holly hovercrafter at earthlink.net
Mon Jan 19 15:07:24 UTC 2015


How are you associating the rooms content type to the reservations one? 
If you're using entity reference, then you would want to create a 
relationship with the reservations content type through that reference 
field. Make sure you don't check "require this relationship" then add a 
filter so that the related node (reservations) nid is NULL.

The other option is in a custom module, using hook_views_query_alter. 
Load the reserved room nids, through a normal DB query, then add a NOT 
IN condition to the list of nids. Here's the documentation on that hook:

https://api.drupal.org/api/views/views.api.php/function/hook_views_query_alter/7

Jamie Holly
http://hollyit.net

On 1/19/2015 9:37 AM, Lluís Forns wrote:
> I have a site with 2 content types: rooms and reservations. I want to 
> list all the rooms without a reservation for an interval, and also for 
> services, capacity, ....
>
> I tried creating a view with a PHP filter to check free rooms, but 
> then if the page lists 10 rooms, sometimes there are 7, 2, or 0; 
> because the filter lists the 10 rooms and after remove the occupied ones.
>
> I have tried to create a "subview" filter to select nodes "not in 
> (view of occupied rooms); but I haven't find a way to do so.
>
> Any idea of how to accomplish this?
>
> thanks
> -- 
> *Ser freak no és imprescindible per ser informàtic, però ajuda.
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20150119/cb0868c9/attachment-0001.html 


More information about the support mailing list