Along the same lines as #839810: User ID from URL default arg plugin doesn't find views arguments - blocks don't receive the default argument when looking at a page view that takes Taxonomy Term ID from URL as an argument.

Comments

marcp’s picture

Status: Active » Needs review
StatusFileSize
new996 bytes

Patch is attached.

bonobo’s picture

Any word on this?

dawehner’s picture

Can you explain why you do this?

Default argument's are only used when Action to take if argument is not present: which is not the case here. I don't see the point why it's needed currently.

bonobo’s picture

The use case is similar to what is described here - the argument works for the page display, but doesn't work for the block display.

This patch addresses the issue.

bonobo’s picture

Any word on this?

k3n3dy’s picture

I'm experiencing this problem. It seems Views just doesn't see the tid argument in the URL. I applied the patch but nothing changed.

Using Drupal 6.19
Views 6.x-2.11
Faceted Search 6.x-1.x-dev

Everything works as expected with pages. When I use blocks (and I need it) it just doesn't work at all.

Any suggestion is very much appreciated.

Thanks.
Kenedy

merlinofchaos’s picture

Ok. My apologies about the delay getting to this. The Views 'needs review' queue is very large and there's a large number of patches that have sat for awhile.

Ironically, bumping the patch in your case made it wait longer, because when I do try to hit the needs review queue,I go oldest first. Bumping it moves it to the top, so I assume it hasn't been waiting as long and it doesn't end up getting consideration. Go figure.

I think this patch makes sense. However, a patch for just 6.x-2.x can't be committed. I need patches for 6.x-3.x primarily, and then I have to consider if this is serious enough to put in 6.x-2.x. This is not technically a bug, this is a new feature. I've let some new features into 2.x when I figure they're valuable enough to deal with the potential disruption. I'm wavering on this. I don't see that this one really needs to go into 2.x but I also don't see it as too disruptive.

merlinofchaos’s picture

Status: Needs review » Needs work
marcp’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new954 bytes

Patch for 6.x-3.x is attached.

You can test it out quickly with the following view which provides a page accessible at termposts/% and a block that should show up on any page where tid is an argument. Before applying the patch, the block will not appear when viewing termposts/%.

$view = new view;
$view->name = 'term_posts';
$view->description = 'Posts in a given term';
$view->tag = '';
$view->base_table = 'node';
$view->human_name = 'Posts in a given term';
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '20';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all'] = 0;
$handler->display->display_options['style_plugin'] = 'table';
/* Field: Node: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
$handler->display->display_options['fields']['nid']['element_label_colon'] = 1;
$handler->display->display_options['fields']['nid']['element_default_classes'] = 1;
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
$handler->display->display_options['fields']['nid']['link_to_node'] = 0;
/* Field: Node: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 1;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Taxonomy: All terms */
$handler->display->display_options['fields']['tid']['id'] = 'tid';
$handler->display->display_options['fields']['tid']['table'] = 'term_node';
$handler->display->display_options['fields']['tid']['field'] = 'tid';
$handler->display->display_options['fields']['tid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['tid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['tid']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['tid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['tid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['tid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['tid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['tid']['alter']['html'] = 0;
$handler->display->display_options['fields']['tid']['element_label_colon'] = 1;
$handler->display->display_options['fields']['tid']['element_default_classes'] = 1;
$handler->display->display_options['fields']['tid']['hide_empty'] = 0;
$handler->display->display_options['fields']['tid']['empty_zero'] = 0;
$handler->display->display_options['fields']['tid']['link_to_taxonomy'] = 1;
$handler->display->display_options['fields']['tid']['limit'] = 0;
$handler->display->display_options['fields']['tid']['vids'] = array(
  1 => 0,
);
/* Argument: Taxonomy: Term ID */
$handler->display->display_options['arguments']['tid']['id'] = 'tid';
$handler->display->display_options['arguments']['tid']['table'] = 'term_node';
$handler->display->display_options['arguments']['tid']['field'] = 'tid';
$handler->display->display_options['arguments']['tid']['default_action'] = 'default';
$handler->display->display_options['arguments']['tid']['style_plugin'] = 'default_summary';
$handler->display->display_options['arguments']['tid']['title'] = 'Posts in %1';
$handler->display->display_options['arguments']['tid']['default_argument_type'] = 'taxonomy_tid';
$handler->display->display_options['arguments']['tid']['default_argument_options']['term_page'] = 1;
$handler->display->display_options['arguments']['tid']['default_argument_options']['node'] = 0;
$handler->display->display_options['arguments']['tid']['default_argument_options']['limit'] = 0;
$handler->display->display_options['arguments']['tid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['tid']['add_table'] = 0;
$handler->display->display_options['arguments']['tid']['require_value'] = 0;
$handler->display->display_options['arguments']['tid']['reduce_duplicates'] = 0;
$handler->display->display_options['arguments']['tid']['set_breadcrumb'] = 0;
$handler->display->display_options['arguments']['tid']['use_synonym_for_summary_links'] = 0;

/* Display: Term posts page */
$handler = $view->new_display('page', 'Term posts page', 'page_1');
$handler->display->display_options['path'] = 'termposts/%';

/* Display: Term posts block */
$handler = $view->new_display('block', 'Term posts block', 'block_1');
$handler->display->display_options['defaults']['pager'] = FALSE;
$handler->display->display_options['pager']['type'] = 'mini';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all'] = 0;
$translatables['term_posts'] = array(
  t('Defaults'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort By'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('Nid'),
  t('Title'),
  t('All terms'),
  t('All'),
  t('Posts in %1'),
  t('Term posts page'),
  t('Term posts block'),
);
Als’s picture

Applied the patch for Views 2.x but problem not solved (like #6).

Using Drupal 6.17 + Views 2.11 + block view. Working perfectly in preview, with tid argument entered manually.

I see the problem also in standard nodes, so I suppose the "taxonomy term ID from URL" does not work at all (not just in page views) when standard paths are tweaked by Pathauto, which is essential for SEO.
Hope the patch can be accepted, 10 rows to correct URL scanning seems not a great risk?

I have worked around the problem switching the "default argument type" to PHP code and using the following:

1) With Drupal's original links. Always valid as real URLs remain active even when aliased:

if (arg(0) == 'KKKKK' && arg(2) != '') {
return arg(2);
}

Where
- arg(0) = reference to specific paths ('KKKK'). Optional, prevents unexpected behaviour if the argument is used in URLs all over the site.
- arg(2) = assuming that taxonomy id is the 3rd part of the URL.

Example
URL: http://www.sitename.com/KKKK/page/1
KKKK will be read as arg(0), 1 will be arg(2) and returned as tid.

2) With aliased URLs:

$pageurl = drupal_get_path_alias($_GET['q']);
$pageurl = explode('/', $pageurl);
return $pageurl[2];

Where
- first row reads aliased URL
- second row splits it in an array
- third row returns the third value of the array as taxonomy id. This is where it is found in our Pathauto configuration.

Example
URL: http://www.sitename.com/news/city/1
The array has values 0 = news, 1 = city, 2 = 1. The last one is returned as taxonomy id.

dawehner’s picture

So if the patch doesn't work the status might have to be changed to neews work again.

Als’s picture

Not changing the status because I tested the patch for Views 2.x, while the Views 3 version has already been submitted here.
Just wanted to confirm that, without the Views team examining the patch for Views 3, the 2.x version does not help (at least, not everyone!)

In the meantime, I made #10 more detailed.

marcp’s picture

@Als - The patch is for 3.x. If you are able to test it against 3.x that would be most helpful. Thanks!

Als’s picture

Yes Marc, I tested the patch for Views 2 (post #1).
At the moment we do not use Views 3, but we are going to update a site in the next weeks. That will be the opportunity to test and report here.

merlinofchaos’s picture

Status: Needs review » Fixed

looks good. Committed to Views 3 in D6 and D7.

Status: Fixed » Closed (fixed)

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