views:

308

answers:

5

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?

+1  A: 

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.

marcvangend
The "Sticky" status worked like a charm and required no hacks! Woo hoo. Thanks.
Kevin
A: 

for drupal 5 there was views union. Someone started something for D6, but I don't know how far they got.

http://drupal.org/node/275162

easement
+1  A: 

Along the lines of the 'sticky' idea, if you didn't want to override that, maybe you could add a checkbox field to the company type -- isClient. Make it false for everyone except the client, and sort by that.

I haven't done this, but maybe you need to create both versions as attachments, and attach them both to another display...?

sprugman
A: 

Create the second view as an attachment and attach it to first.
Set all Inherit arguments, Inherit exposed filters and Inherit pager to Yes.

farzan
Thats what I did, but it shows 2 pagers where one view ends and the other begins.
Kevin
Well, I created a test view like this:- A page display with a filter.- An attachment display with another filter.- I attached the attachment "before" the main display.- I set the Inherit arguments, Inherit exposed filters and Inherit pager to Yes and Render pager to No.It worked _almost_ fine. A pager appeared under the main display that affects the attachment.But there is a big problem that I think it makes you reconsider all the approach: if the attachment display has more "pages" to display than main display, you cannot access them. Pager has only links to main display pages; no more.
farzan
A: 

how is the client parameter passed to the view? as an url argument? if so, you can create your second view like i outline here and then select the exclude the argument option on the appropriate location.

Peter Carrero
CompanyID just comes from a filter
Kevin