I'd like to filter by a particular vocabulary that has multiple terms. I'd like the view to only show, for example, the most recent node from each term associated with that vocabulary. Currently, it appears that the only way to do this would be to create separate views for each term and then use views fusion to combine them. But this is rather tedious and creates a lot of extra work if one has very many terms, and then there are so many extra views to manage. if this could be done within one view, it would be awesome.

Comments

merlinofchaos’s picture

Status: Active » Closed (won't fix)

It would be awesome.

Alas, it is simply not possible with the current architecture.

cpelham’s picture

Merlin, might it be possible in Views 2?
If this feature might get added in next year, I could wait for it. Otherwise, I'll just go ahead and use Views Fusion.

merlinofchaos’s picture

I don't think so, because of the way SQL works, it's hard to do a limit per group; you can only do overall limits or group down to 1. I can't really think of a way to do it in one query, and Views basically wants it done in a single query.

davoso’s picture

Version: 5.x-1.6 » 6.x-2.2
Category: feature » support
Status: Closed (won't fix) » Active

Hi, i'm new in drupal, but i think views is by far one of the best modules (of those i saw so far).

I asked the same question (but i work with views 2), for solve your question, i did a style plugin, here is an implementation to group the results of the query (render_grouping method), and in the options of the new style i added a new field (number of items per group) but this works only if the items per page is unlimited because this function is called with only the number of rows in items per page.

good:
- You have a limit per group (more less, only you can group by one field).

bad:
- you have to ensure your query don't have to much items.
- you have to use that plugin (or probably you could modify views module code (views_plugin_style class) ).

dawehner’s picture

Status: Active » Closed (won't fix)

I don't think so, because of the way SQL works, it's hard to do a limit per group; you can only do overall limits or group down to 1. I can't really think of a way to do it in one query, and Views basically wants it done in a single query

this is won't fixed, its quite impossible to do it with sql

Oscar Illada’s picture

Version: 6.x-2.2 » 6.x-2.6
Category: support » feature

I was looking for the same solution, i see that a lot of month pass away and nothing was done, if some one have the answer let me know.
Thanx and Drupal RULESSSSSSSSSSSSSS, greetings from Uruguay

xjm’s picture

See #4. It doesn't have to be done in SQL; it can be done with a style plugin. davoso, might it be possible to post your plugin in this issue as others might find it useful?

mr.andrey’s picture

Version: 6.x-2.6 » 6.x-2.8
Status: Closed (won't fix) » Active

I'm actually very interested in figuring out a way to show the top three entries for each of the users.

What if we do a PHP argument that pulls only the top three nodes for each user (of a particular role)?

I have a query that almost does this, but I can't get it to sort correctly.

Here's the basic idea:

SELECT n.uid, n.nid, @i:=@i*(@prev=n.uid)+1 i, @prev:=n.uid prev
FROM (select @i:=0, @prev:=0) t, node n
ORDER BY n.uid, n.nid desc;

The basic principle is that we add a dynamic counter column, which resets on every new uid.

uid 	nid 	i 	prev
1 	526 	1 	1
1 	525 	2 	1
1 	524 	3 	1
1 	523 	4 	1
1 	522 	5 	1
1 	521 	6 	1
1 	520 	7 	1
1 	519 	8 	1
1 	518 	9 	1
1 	517 	10 	1
1 	516 	11 	1
1 	515 	12 	1
1 	511 	13 	1
3 	218 	1 	3
3 	204 	2 	3
8 	507 	1 	8
66 	514 	1 	66
66 	513 	2 	66
66 	512 	3 	66

Add a "HAVING i <= 3" statement, and it should pull the top three results.

Now this is the version with limiting by role:

SELECT n.nid, @i:=@i*(@prev=n.uid)+1 i, @prev:=n.uid prev
FROM (select @i:=0, @prev:=0) t, node n
INNER JOIN users_roles ur ON n.uid = ur.uid
WHERE ur.rid = 7
ORDER BY n.uid, n.nid desc;

... and this is what I get:

526 	13 	1
525 	12 	1
524 	11 	1
523 	10 	1
522 	9 	1
521 	8 	1
520 	7 	1
519 	6 	1
518 	5 	1
517 	4 	1
516 	3 	1
515 	2 	1
511 	1 	1
514 	499 	66
513 	498 	66
512 	497 	66
510 	496 	66
509 	495 	66
508 	494 	66
505 	493 	66
504 	492 	66

Unfortunately if I use the INNER JOIN, I can't get the "i" counter to assign as in the first query. It pulls the lower number nids first, rather than the highest as ORDER BY statement specifies.

Any ideas?

Best,
Andrey.

esmerel’s picture

Status: Active » Closed (won't fix)

No patch, no activity in 3 months.