0

I have multiple content types, which are in some ways related to each other. Lets say, the first one is "Author". Other ones are "Novel", "Drama" and "Short Story", which each reference "Author" (using the same field for each content type, so I can create relationships easier later in the view). Now I want to create a view table like this:

Author Novels Dramas Short Stories
King, S. It, Insomnia, ... ... Rush Call, ...
Martin, G. R. R. ASOIF, ... ... ...
... ... ... ...

For each author there should be one(!) row in the table and for each text type they wrote there should be a column in the table showing the titles of that text type comma separated.

How can I achieve this output using views? I tried different ways of grouping and aggregation, but none of them quite worked. For example, when I try to group by "Novel", the tables split and it looks awful. I would have no problem styling the final results in a custom template, but what can I do using core views to get to my desired outcome a little bit easier?

0

I don't see a way of creating with vanilla Views, that without changing the templates.


Starting from the Author Views is the worse path to take. You can use reverse Relationships to show nodes that reference a particular Author, but they will be in separate rows, reverse Relationship doesn't support Multivalue options that you get when directly displaying an ER field.


The best path seems to be to create Content Views that lists all "Novel", "Drama", and "Short Story" nodes. Add the Title Field, Author ER, and the CT (type).

(I don't know if there is some magical Agreggate trick that could work to your solution, the usual ones I've used aren't sufficient for something like this.)

Hide the Author field with Exclude from display and then under Format Settings select the Author field as the Grouping field.

This will still give you each book in its own row, but they will be grouped by their authors. With some template changes you can change the grouping to appear within the table so it appears more like you'd like, with the Author as a column that spreads multiple rows (their work) and all results can be displayed within one table where each author info is within separate tbody elements.

With some more templates adjusted I think you could get to construct exactly the table you want where work nodes of the same type are printed out in the same cell, and types come out as columns, but it wouldn't be trivial.


You might also try the Views Field View module. This is usually used to embed Views within Views (that are related through a field such as an ER field) but it can be very heavy on the performance!

I also haven't tried it under the reverse condition, assuming you start from the author and then get to the relating nodes through backwards Relationships. But OTTOMH it seems possible, you could list all work in the same table row as the Author, each work would still be in a separate row but you could group them by type though. The types wouldn't display horizontally like in your case, but vertically, still it would be close to what you want to achieve. And you could use templates to replace the output of the "embedded" Views (works) to match it closer to what you had in mind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.