I have used views 2 on several sites so far and I love it. I've been able to make it do everything that I needed except for this one thing. I've tried work arounds but ended up coming back to having to do it this way - but I can't figure it out.

I have a views page that is outputing the row style as nodes. I have to use nodes so that I can properly format the output. The problem is that I need to group the nodes by taxonomy term.

Example:

++++++++++++++++++++++++++++++++++++

Dinner Menu

Steaks <-- taxonomy term

menu item <-- node
menu item <-- node
menu item <-- node

Seafood <-- taxonomy term

menu item <-- node
menu item <-- node
menu item <-- node
++++++++++++++++++++++++++++++++++++

When I output the view as fields, I can create a field to properly group and display the taxonomy term - but when I output as nodes (like I have to do) I can not figure out how to achieve this.

Is this possible?

Please, please help!

Comments

merlinofchaos’s picture

Unfortunately, Views grouping feature requires fields, and the 'node' row style doesn't use them. So Views can't do this for you. It may be possible to do clever stuff via theming to accomplish this, but it's fairly advanced and I'm not even sure it can be done.

3cwebdev’s picture

Thanks for your response! Is there any way to 'string' multiple pages views together?

Like this: create a view that shows the steak dinner items and use the word "Steaks" in the header. Then create additional page views with different headers representing what would be the taxonomy term and show them on the same page. If I could somehow group the different page view items together it would accomplish the same thing... possible??

merlinofchaos’s picture

Sure, create attachment displays. They'll 'attach' to the selected display (be sure to tell them which displays to attach to!) and this lets you have several views on one page.

avior’s picture

Hi
did you managed doing this ?
i have the same issue , please share how you did this

Term 1
- node 1
- node 2

Term 2
- node 3
- node 4

3cwebdev’s picture

I was able to achieve the result that I needed by using views fields output type and then using views themes to achieve the specific output that I needed. Once I figured out how to use them, I found the views themes to be very flexible.

avior’s picture

So i understand you parsed the html ?

As i can see you can change the : views-view-TYPE--VIEWNAME.tpl.php
but from what i understand if you want to change the layout, for instance add extra UL in the middle, you have to parse the html , i don't have the view object there

Did i understand correctly ?

3cwebdev’s picture

Yes, you have a lot of control of your views output from it's templates. If you haven't already I would be sure to go to views->basic settings->Theme information and look through the different templates available. You should also have Advanced Help module installed and use it's help get further details.

I believe that you have to have node type set to fields first before clicking Theme Information to be able to see the proper templates available for field type views.

hth

avior’s picture

giorgio79’s picture

I would have liked to achieve sg similar.

Namely, I have a 3 level hierarchical taxonomy, and I wanted to group by only the second level terms to get the most viewed items for each term in that level...

I think I will write a custom SQL query and pass the resulting nodeids as arguments for now :)

3cwebdev’s picture

Status: Active » Closed (fixed)
marcushenningsen’s picture

Version: 6.x-2.0-rc1 » 6.x-2.x-dev
Component: Documentation » User interface
Category: support » feature
Status: Closed (fixed) » Active

This issue is causing me some trouble as well.

I would love to be able to make a view of content type X grouped by taxonomy term and have it displayed as full nodes (i.e. row style = node). I want the node row style because this seems to be the only way to let me have the comments for each node displayed as well.

An attachment for each term is not really a solution, since terms aren't static.

Use row style = fields makes it possible to group, but using fields isn't a good solution if I want both node bodys and comment bodys, since adding a comment field (e.g. Comment: Body) gives me a row for each comment and thereby dublicating the node body field. Also described here: http://drupal.org/node/533436

The only workaround I see is to:
1) install the Taxonomy Node module and the Views Attach module
2) create a new content type Y and set Taxonomy Node to use this for the given vocabulary terms
3) add a new view with a "node content" display, "row style = node" filtered by content type X, with a term argument, under "node content settings" embedded into content type Y and with token "title" as argument
4) add another view with a "page" display, "row style = node", filtered by content type Y

This seems to work, but it is of course pretty complex, involving 3 modules instead of 1, 2 content types instead of 1, and 2 views instead of 1. Does anyone have a better solution? Perhaps in some way making it possible to group while choosing node row style? Or perhaps in some way making comment fields work as expected, i.e. being able to group comments in one field. Or perhaps a whole new approach?

marcushenningsen’s picture

Title: Possible to output nodes and still group by Taxonomy term? » Possible to output nodes (with comments) and still group by taxonomy term?
Version: 6.x-2.x-dev » 6.x-2.8
Status: Active » Fixed

I tag this issue as fixed, because I fixed it, for myself at least!

When I asked I had no clue what setfree and avior were taking about, but I finally got to have a fresh look at the issue, and here is what I did:

To summarize, I wanted a view of nodes with their comments, grouped by a taxonomy term.

First, I created a node view with fields. Basically just two fields are needed; nid and taxonomy term. I removed the label from nid field, I excluded the taxonomy term field, I chose unformatted style and then I grouped by the taxonomy term.

Second, into my theme folder I copied the views-view-field.tpl.php file from the views theme folder, then I renamed it views-view-field--[my view]--nid.tpl.php, and edited it to look something like this:

<?php
  //print $output;
  $node = node_load($row->nid);
  print node_show($node, $cid = NULL);
?>

Voila! This code parses the whole node and its comments. I actually use this in a calendar through views, so advanced views theming just opens up a lot of new possibilities.

If you need more specific information, feel free to comment on this issue. I hope it may help someone.

Marcus

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jp2020’s picture

Hi Marcus,
Could you show an example. This might prove to be useful to me.
Thanks,
JP

ressa’s picture

Thanks marcus, I followed your example and it works perfectly!

mathieuhelie’s picture

#12 You've spared me a good 5 hours of forehead-to-the-wall.

mstrelan’s picture

I too am looking for this functionality and was hoping to avoid going down the route of #12, but it seems like this is the only way out. Thanks everyone for the confirmation on this.

ressa’s picture

Perhaps the Node comments module can help you? http://drupal.org/project/nodecomment

chronosinteractive’s picture

marcushenningsen - ingenious solution!

jnettik’s picture

Just wanted to add that #12's solution works in Drupal 7 with one addition:

  $node = node_load($row->nid);
  print drupal_render(node_show($node, $cid = NULL));

node_show() creates another array that needs to be rendered, hence the wrapping in drupal_render(). Thank you for posting that. Saved me a ton of time and work.

Edit: node_show was only rendering full node content, not teasers. I amended the above to this for teasers:

  $node = node_load($row->nid);
  print drupal_render(node_view($node, $view_mode = 'teaser'));