If a taxonomy term contains a slash in the URL, the link used in summary mode is incorrect.

Example:

Taxonomy term:
"Nassau / Paradise Islands"

URL to taxonomy page
http://sandbox.6/category/islands/nassau-paradise-islands

URL to taxonomy page as generated by Views:
http://sandbox.6/category/nassau-/-paradise-islands

As you can see, it has an extra slash and dash in it.

Comments

merlinofchaos’s picture

Status: Active » Closed (won't fix)

The URL you're showing is clearly an alias. The alias is generated by pathauto. Pathauto uses a formula that is entered by the user to create the alias. The final alias exists in the database as a full path.

Views has no way of knowing the pieces pathauto used to generate that view, so you are not going to be able to use the summary view to try and mimic pathauto. This is not a bug, this is an incorrect expectation. What you're trying to do simply is not going to work.

mrfelton’s picture

Status: Closed (won't fix) » Active

ok, but Views has a feature that lets you accept the term name as an argument to the view (clearly using a term ID is a better approach, and I got round this problem by adjusting the view to use the tid instead). If views will accept the term name as an argument, should it not ensure that url that is generated by the 'summary, sorted' mode is an internal link to the taxonomy page (taxonomy/term/[tid]) which will always work, rather than trying to make some kind of best guess at what that path might be. In most cases it works, especially if you the 'convert dashes to spaces' - but it doesn't work if your taxonomy term as a slash in it.

As far as I could make out, it is a combination of this (theme/theme.inc, line 239):

/**
 * Preprocess theme function to print a single record from a row, with fields
 */
function template_preprocess_views_view_summary(&$vars) {
  $view     = $vars['view'];
  $argument = $view->argument[$view->build_info['summary_level']];

  $url_options = array();

  if (!empty($view->exposed_raw_input)) {
    $url_options['query'] = $view->exposed_raw_input;
  }
  $vars['classes'] = array();
  foreach ($vars['rows'] as $id => $row) {
    $vars['rows'][$id]->link = $argument->summary_name($row);
    $args = $view->args;
    $args[$argument->position] = $argument->summary_argument($row);

    $vars['rows'][$id]->url = url($view->get_url($args), $url_options);
    $vars['rows'][$id]->count = intval($row->{$argument->count_alias});
    if ($vars['rows'][$id]->url == base_path() . $_GET['q'] || $vars['rows'][$id]->url == base_path() . drupal_get_path_alias($_GET['q'])) {
      $vars['classes'][$id] = 'active';
    }
  }
}

And this (handlers/views_handler_argument_string.ing, line137):

  function summary_argument($data) {
    $value = $this->case_transform($data->{$this->base_alias}, 'path_case');
    if (!empty($this->options['transform_dash'])) {
      $value = strtr($value, ' ', '-');
    }
    return $value;
  }

That is the problem... It takes the name of the term, replaces spaces for dashes, and generates a URL from that to be used in the summary link. Shouldn't it be using the tid instead, and generating a link to /taxonomy/term/[tid] which will always work?

merlinofchaos’s picture

Summaries link back to itself. You're trying to suggest it should link somewhere else entirely.

If that's what you want, you need to theme the summary and change the link.

mrfelton’s picture

What do you mean by they link back to themselves?

Letharion’s picture

Status: Active » Closed (fixed)

Hello!

I'm cleaning up the Views issue queue, and thus trying to close open support requests that have had no activity in the past 6 months or more. If this is still a relevant please reset the status to active, and the new bug squad will make an attempt at the problem.

jakew’s picture

Status: Closed (fixed) » Active

I had to change a site to use tid instead of name in the url because someone started using a slash in a taxonomy term. It was really nice to have the actual name of the term reflected in the url. Is there any way to get this back without breaking it again? If not, this bug should still be open.

pelicani’s picture

we can change the base URL of the summary link to point to the taxonomy view.
but when the term contains a term that path auto strips out, the links break.
i.e. if you have a slash in your term, path auto strips it out, but the summary keeps it in.
this approach seems logical, is there an alternative way to display a summary of taxonomy terms that link to the taxonomy page?

pelicani’s picture

Version: 6.x-2.x-dev » 7.x-3.7
Category: Bug report » Feature request
Issue summary: View changes