I've been using views for a long time and it's great. Lately I've been trying to figure out a way to create a view that will return 1 node from many categories of nodes. Example: say I have 3 taxonomy terms with a bunch of nodes that have been given a single taxonomy term:
Category1:
blue
red
green

Category2:
apple
pear

Category3:
car
bike
motorcycle

I'd like to build a view that will return:
Category1:
blue

Category2:
apple

Category3:
car

I can do this with a bunch of theme overrides...but have been wondering if there's a way to do this without theming the view.

Any tips?
thx
pp

Comments

ppmax’s picture

Any ideas?

scottprive’s picture

I have a similar problem. I added Views to the Recipe Module, but when you build a view like this:
Title
Notes
Instructions
Ingredient1 Ingredient2 Ingredient3

... then your results are:
Title Notes Instructions Ingredient1
Title Notes Instructions Ingredient2
Title Notes Instructions Ingredient3

Sounds like your problem right?

.. so we get field duplication due to how the SQL JOIN works. DISTINCT will just lock this down to 1 row, and you will get 1 ingredient.
Not really a Views problem in the strict sense (I have been told as such, but I don't fully understand why Views can not detect and filter the 1:N relationship as an option.)

Anyways, the direction I have been pointed at Taxonomy: All Terms or Node: Attached Files, specifically taxonomy.views.inc and upload.views.inc
This has one:many content handlers that grab all of the "many" and return it such that it can be displayed in 1 row.
There are no known tutorials for this issue, so all we have is the source code. I understand the concepts, but have not spent enough time debugging it to benefit from these 2 examples.

If you want to work on this together you can PM me. I really need to understand this myself.

If you can, I would change this topic from Theme development to Views2 so more of the correct people see it.