All taxonomy terms is very useful, but sometimes you need just 2 or 3 term names,not all of them.
Wouldn't it be great to limit the number of terms showing up?

I guess it is something easy, but i don't have any coding experience with views:(
Maybe could someone guide me and i could get the patches ready

Comments

dawehner’s picture

If you would like to add this feature you would have to add something to views/modules/taxonomy/views_handler_field_term_node_tid.inc

ParisLiakos’s picture

Status: Active » Needs review
StatusFileSize
new1.83 KB

Thanks for the hint,helped me a lot:)

Couldn't find a way to apply it to the query, except groupby() but that would give me one term.
So i applied it in the foreach loop.

dawehner’s picture

Status: Needs review » Needs work
+++ b/modules/taxonomy/views_handler_field_term_node_tid.incundefined
@@ -32,6 +32,7 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li
+    $options['limit_items'] =  array('default' => FALSE);

It seem to make more sense to provide 0 as no limit by default.
In general it should be possible to limit the query, hopefully.

ParisLiakos’s picture

Yes i tried limiting the query,first thing but this query returns the terms for all the current nids.
So if i apply range() to the query it will get the first terms from all the nodes aggregated.

I dont think there is a way to apply a limit inside the query for each node

ParisLiakos’s picture

StatusFileSize
new1.82 KB

Changed it according to #3

ParisLiakos’s picture

Status: Needs work » Needs review
deggertsen’s picture

I was able to port the patch in #5 to the 6.x-3.x-dev branch. See #668230: Limit values displayed of field "Taxonomy:all terms".

Thank you rootatwc, patch appears to work great!

ParisLiakos’s picture

No problem:) patch indeed works,but still the best way would be to filter them inside the query,but maybe its not possible...maybe an sql guru could help more,but this is the best solution i could find.cheers

dawehner’s picture

Marked the other issue as duplicate to keep things easy.

tim.plunkett’s picture

Triggering the testbot.

Status: Needs review » Needs work

The last submitted patch, limit_term_results-1266516-5.patch, failed testing.

ParisLiakos’s picture

StatusFileSize
new1.85 KB

hmm patch now fails,so i recreated it agtainst latest dev

ParisLiakos’s picture

Status: Needs work » Needs review

oops.status change

marcoBauli’s picture

some work going on about something similar for 6.x-2.x-dev here: http://drupal.org/node/769136

dagmar’s picture

Status: Needs review » Needs work
+++ b/modules/taxonomy/views_handler_field_term_node_tid.inc
@@ -38,6 +38,7 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li
+    $options['limit_items'] =  array('default' => 0);

There is an extra space after the =.

+++ b/modules/taxonomy/views_handler_field_term_node_tid.inc
@@ -52,6 +53,13 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li
+      '#title' => t('Limit quantity of terms to show'),
+      '#default_value'=> $this->options['limit_items'],
+      '#fieldset' => 'more',

I think you should provide more help in the description. Something like. Use 0 to display all the terms.

+++ b/modules/taxonomy/views_handler_field_term_node_tid.inc
@@ -112,6 +120,12 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li
+          ? count($this->items[$term->node_nid]) >= $this->options['limit_items']

Mmm. I'm not really sure if $term->node_nid is enough flexible.

I mean, nodes are not the only entities that can be categorized.

matt v.’s picture

Status: Needs work » Needs review
StatusFileSize
new1.91 KB

I've updated ParisLiakos's patch from #12 to incorporate most of dagmar's suggestions from #15.

Regarding dagmar's comment that "...nodes are not the only entities that can be categorized," I didn't make any changes to that section because this part of the Views code (views_handler_field_term_node_tid) appears to be concerned specifically with terms on nodes.

I did change the name of the new limit from "limit_items" to "limit_quantity" because it seemed more descriptive to me.

It didn't make sense to me that the new option was relegated to the "More" section at the bottom of the modal window. I wasn't initially able to find the new form field, until I first looked at the code. That said, I didn't change it, but I think it would be something to consider.

chris matthews’s picture

Issue summary: View changes

The 5 year old patch in #16 to views_handler_field_term_node_tid.inc applied cleanly to the latest views 7.x-3.x-dev and if still applicable needs review.

Checking patch modules/taxonomy/views_handler_field_term_node_tid.inc...
Hunk #1 succeeded at 45 (offset 7 lines).
Hunk #2 succeeded at 60 (offset 7 lines).
Hunk #3 succeeded at 131 (offset 10 lines).
Applied patch modules/taxonomy/views_handler_field_term_node_tid.inc cleanly.