How do I make a view that groups nodes by taxonomy term? - drupal

I'm trying to bend views and drupal to my will. So far I've produced a view to display the titles of my nodes. Each node will be assigned exactly one taxonomy term from the set {X, Y and Z}.
So for example, Node A has a title "Car drives into field, thousands don't care". Node A has a taxonomy term "Pointless".
I'd like to group all the node titles by their taxonomy term. So..
Pointless
- Car drives into field, thousands don't care
- ....
Next Taxonomy Term
- .....
- ......
- ...
You get the idea. Is it doable and how do I do it? I can't find the group by option in views.
cheers SO.

You can use grouping when you use the table row style. Doing that you can group by any field you include in your view.
You could also try out taxonews which could work for your case.

#googletorp's answer is a good one. You might also pseudo-group by including the term field and sorting on it.

You can use Views Grouping Row Limit module, http://drupal.org/project/views_limit_grouping.
In addition, if you want to limit the number of groups, you can apply a patch for that module, http://drupal.org/node/1315888.

Related

calling of one taxonomy from another taxonomy, so both of them have used in the same content type

Can we call one taxonomy term from another as a parent and child relation for example I need to click on product category and that show me product series page and when I click on product each series that will lead me to actual product detail means node, so I have two taxonomies category and series I am about to click on category to carry me to series page and then to click on series page to carry me to product detail page on the concern series”
no codebase problem
i am expecting that these two taxonomies may be used as i have mentioned in the question summary but, i can't do it so i hope some help in resolving this issue
Let's look at this answer, I hope it will help you.
Taxonomy terms from the same vocabulary filtered and referenced on multiple content types
To do this you’ll need to have the Entity Reference module installed. So get that out of the way quickly with drush dl entity reference -y and drush en entityreference -y if you haven't already.
First up, we need the taxonomy set up.
Let's demonstrate with the help of an image.
You’ll notice that these terms could be more or less grouped into two categories: Transport and Sleeping. One term (couchette) kinda fits both criteria and is there to exemplify the reason for not using 2 different vocabularies to handle the issue. Now we need to technically make the distinction between these terms as well and since they are entities, we can use a field for that.
So we can now go ahead and add a new field to this vocabulary of the type List (text) with whatever widget you’d like (and let’s call the field Type). You should make the allowed number of values unlimited and put the following in the allowed values list:
Edit each term and select the appropriate type. As expected, for the term couchette, you should select both options.
Now that we have our taxonomy squared away, it’s time to create a View that will handle the filtering of these terms. Because if we now add the Tags taxonomy term reference field to our content types in the normal fashion (as it is already present in the Article content type) we’ll be able to select all the terms in the vocabulary for all the content types. And that's not what we want now.
So create a drupal 7/8 View that shows taxonomy terms of the Tags vocabulary - let’s call it Tags Filter. Add 2 displays of the type Entity Reference and a filter of the field we added to our terms earlier. So for instance the first display can show the terms which have Sleeping selected and the other one can show terms which have Transport. Save the View and you can close it.
Now finally we can edit our content types and add to each a new field of the type Entity Reference with a select list widget. For the target type select Taxonomy term and under Entity Selection choose the following: for Mode, go with Views: filter by entity reference view and then select the View in question - one of the two displays which we created earlier. In the picture below, I named one of the displays

Add view filter to retrieve content associated with one or more Taxonomy Term IDs

I have created a Drupal 6 view which has two "Taxonomy: Term" (Term ID) filters, for two different taxonomy terms. I need to create a feed that pulls content that is associated with a OR b, or that is associated with a AND b. Currently, nothing is displayed because it seems that the logic of two filters is AND, not OR.
How do you pull content that has the logic OR with Drupal views?
It does work if there is only one filter, but as soon as I add a second filter, zero records are found.
The OR filter is not built in to Views2. For ways to get around this, see http://groups.drupal.org/node/16173. And this old post might help as well OR operator in Drupal View Filters

Drupal6 views: output "taxonomy:all terms" field with two terms as two links

Briefly: I'm making a custom view, I want a field listing the two taxonomy terms associated with an NID to output as two distinct links which return arguments for the view (term1 to view/term1, term2 to view/term2. Rather, it outputs as one aggregated link (both term1 and term2 output view/term1%0Aterm2.
Am I doing something wrong or is this not possible?
Exhaustively:
I am constructing a view of products (with the page output at http://example.com/products) in an drupal ubercart site because the built-in ubercart catalog psuedo-view isn't doing it for me. Some of these products belong to more than one taxonomy term (within the same vocabulary) - for instance, product_example1 belongs to terms blue and glowinthedark, product_example2 red and glowinthedark, product-example3 just blue.
I've created an argument which limits the view based on terms like so: products/red, products/glowinthedark etc returns this nice view I made but only with products which are associated with taxonomy terms red, glowinthedark, etc - so works as it should. Views is awesome!
Now, I want each product shown in this view to link to the generated product/[term] page(s). Outputting the field "taxonomy:all terms" as a link with replacement argument products/[tid] works for one term (product_example3's field works for its one term: /products/blue (views is awesome!) , but, AND HERE'S THE PROBLEM, it DOESN'T FOR TWO TERMS (or I assume more than two terms). This is true whether the field is output as a list or using a simple seperator. So, for product_example one, the field lists both terms blue and glowinthedark (correctly separated as list items or with the chosen "," simple separator), but both terms output the relative link products/blue%0Aglowinthedark.
Is that clear? I haven't been able to google anyone with a similar situation, strangely, although I can't imagine I'm the first to run into this. I may just give up since it's not all that important and I can think of several less-satisfactory but still doable workarounds, but I thought you all might have some insight. The only thing that gives me hope is that when the "Link this field to its term page" check box is selected, views successfully outputs two separate line items with links to the two separate terms' pages.
I'm also posting this question on Drupal.org. Thanks for your time!
Hmmm... strange. I read your question carefully. However I am getting the results that you desire!
I have a taxonomy vocabulary that is multiple select (lets call it "Sector")
I have a taxonomy vocabulary that is single select (lets call it "Location")
In my fields section, I add Taxonomy: All Terms
In the settings for Taxonomy: All Terms I select "Output this field as a link". In there, I set the "Link Path" to product/[tid]
I make sure "Link this field to its term page" is NOT checked
I use a simple comma separator
"Limit terms to a specific vocabulary" checkbox does not matter. It would depend on your business requirements.
As required by you I get products/abc, products/xyz etc. one after another on a single line. This works even if a particular node has multiple terms from the same taxonomy vocabulary. I don't get any %0A stuff.
This works out of the box for me. I tried with both views 2.11 and views 3.0-alpha3
Try upgrading to the latest version of views and see if you have better luck?

Sorting grouped nodes by taxonomy term

Ok, here's the problem:
I have a list of contacts, which i have created in views, that are grouped by taxonomy terms like so:
(term:) Staff:
(node:) John Doe
john#doe.com
(node:) Jane Doe
jane#doe.com
(term:) Management:
Fred Doe
fred#doe.com
and so on...
As it is now, i have no idea what decides the order of the taxonomy terms (ie: why is the 'Staff' nodes coming before the 'Management nodes').
So what i need to do is to be able to sort the order of the terms, and also the order of the nodes in each 'category' (or what you would call it).
I have tried to sort the terms by weight, but the only thing that happens is that i get duplicated nodes output, and nothing happens with the order of the actual terms.
As for the order of the nodes, i was thinking that maybe a hidden CCK-field with some sort of weight, but i dont know. But the biggest problem is still the order of the categories.
If anyone has an answer to this it would be very helpful.
Thank you.
EDIT:
Strange, i tried that before i asked the question, but now it seems to work. However i still get duplicated nodes when i sort by taxonomy weight, for some reason. I really need to get rid of those. Heres how my view setup look, if its any help:
Fields: taxonomy=all terms (limited to one vocabulary)
image attach content
Sort criteria:
Taxonomy weight:descending
Filters: Taxonomy term id(with depth) // to filter out what page it belongs
Node type : contact
node published : yes
dont know if that information helps at all
/Anders
The solution is simple, in views you can sort your result by the taxonomy term. You have 3 options as default.
From the views interface:
Term Taxonomy terms. Note that using this can cause duplicate nodes to appear in views; you must add filters to reduce the result set.
Term ID The taxonomy term ID
Taxonomy Weight The term weight field
The sorting in views, is located in the top right corner, and gives a wealth of options as to how you want to sort your results.
Edit:
Duplicates is a known problem with taxonomy terms. The problem is that if a node has two terms that fit it will be included once for each term. When you use the taxonomy term filter, you can reduce duplicates, which should fix your problem:
http://grab.by/16vw
I seldom have sort problems with views, but I have to admit it's not something I ever really focused on. Here's a short list of things you might wish to check. If that doesn't solve, it would be great if you could provide some more detail on your settings and what appears to be the default sorting in your current configuration.
How did you set the sort criteria in the views UI? You have basic settings available there (top right of the UI panel). See below for some screenshots that should help you finding your way around the configuration.
How did you set your taxonomy term order (accessible from somewhere similar to: http://example.com/admin/content/taxonomy/3 - where the number is the taxonomy ID).
Here is some more information on sorting capabilities of views.
Screenshots on how to configure sorting
NOTE: In this example I show how to sort nodes according to whether they are published or not, but the procedure applies equally for taxonomy terms.
In this view I already set up some sorting, add yours by clicking on the + button
alt text http://img15.yfrog.com/img15/7118/screenshot005vy.png
Select what kind of content you want to sort
link text http://img3.yfrog.com/img3/2341/screenshot006jkz.png
Select the information you want your content to be sorted by
alt text http://img3.yfrog.com/img3/4816/screenshot007nt.png
And finally select the direction of sorting!
alt text http://img37.yfrog.com/img37/9806/screenshot008ah.png
Now you should be good to go! :)
Hope this helps!

Drupal Custom CCK field with multiple child fields

Is there a way of creating a composite field that can have multiple values, with each value having another group of composite values?
E.g. we want to have this structure at the end:
Group 1 (unlimited number of groups)
Child field (unlimited children for each group)
Child field
...
Group 2
Child field
Child field
...
...
Is this possible at all for a custom module that defines a CCK field? If so, can someone push me in the right direction?
this is a very know and debated issue in the drupal world.
this feature is called cck "multigroup" and it looks it's pretty difficult to implement.
there are a lot of posts in the drupal forum about this, i suggest you to start here:
http://drupal.org/node/494100
it's a kind of "hidden" feature in the cck module. looking in the module directory, you will find instructions here:
cck/modules/content_multigroup/README.txt
Edit: Ongoing work on the multigroup module has moved to the experimental
CCK 3.0 branch.
in the meantime you can try to deal with it using the flexifield module
(but it's kinda hackish, i won't use it in production)
I ended up creating my own "Cost/Product" CCK compound field based on this excellent tutorial with example modules: http://poplarware.com/es/articles/cck_field_module
I haven't figured out yet how to pull out a specific sub-field, such as cost, in Views. I only get the entire ": $" compound.
For Drupal 7+, you probably want to check out the Field collection module, or Field group if multiples aren't necessary.
This issue is pretty old, but I just happened across it. I would think the way to handle it for now would be with a second cck type for the children, and the groups as a node_reference field. So you'd have:
MasterType
group field
unlimited per node
each one, a reference to a ChildType node
ChildType
child field
unlimited per node

Resources