Search code examples
drupaldrupal-6view

Combine two views into one view


I have two views that I would like to combine into one.

The first view shows all items of X where company ID = Y. This is to give preferential sort to the client first, and then everyone else.

So I created a second view, all items of X, where company ID != Y.

I created it as an Attachment to attach to the first view, but I don't think I got the intended result.

How can I combine these views so the first view results are listed first, and then the second view is too, using the same pager, filters, and arguments?

Is there any way of achieving this without programming it?


Solution

  • From a MySQL point of view, the order-by-field syntax would be the appropriate way to handle this. Example:

    SELECT * FROM tickets ORDER BY FIELD(priority, 'High', 'Normal', 'Low');
    

    It would be great if there is a module that add this kind of functionality to Views, but AFAIK, it does not exist.

    If you want to solve this without programming, I think you can use the rules module to automatically set the 'sticky' checkbox on nodes where company ID = Y. With that in place, you can order the View on the sticky value.