[support] Views filter rooms by occupacy

Steve Kessler skessler at denverdataman.com
Mon Jan 19 15:52:22 UTC 2015


If you require the relationship it should fix that.

On Monday, January 19, 2015, Lluís Forns <enboig at gmail.com> wrote:

> I was trying to make it without coding a new module; the steps and the
> result are:
>
> 1. created a join, which is no required
> I can list all the rooms with the nid of bookings (if avaliable).
> 2. Created a filter per dates:
> only rooms with bookings for that night are available
> 3. Filter for NULL related booking nid
> No room listed
>
> I think the filter should affect only joined content, but it it is
> affecting the full content. How can I limit to the join?
>
>
>
> 2015-01-19 16:07 GMT+01:00 Jamie Holly <hovercrafter at earthlink.net
> <javascript:_e(%7B%7D,'cvml','hovercrafter at earthlink.net');>>:
>
>>  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 Hollyhttp://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.
>>
>>
>>
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>
>
>
> --
> *Ser freak no és imprescindible per ser informàtic, però ajuda.
> *La vida no ha de ser feliç, ha de ser plena.
> *Abans d'imprimir aquest missatge, pensa en el medi ambient.
>


-- 
Steve Kessler
Owner and Lead Consultant
Denver DataMan, LLC
303-587-4428
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20150119/056a7d1f/attachment.html 


More information about the support mailing list