Views contextual filters have an option to "Transform spaces to dashes in URL." If this option is selected, and you try to use the argument as a token in Metatag, the dashes are included in the output. The dashes should be automatically removed since they are meant to be spaces in between words.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

Can you please confirm which exact token you were using?

herd45’s picture

FileSize
26.45 KB

The behavior described above is true for all of these tokens.

[current-page:url:args:first]
[current-page:url:args:last]
[view:url:args]
[current-page:url:args]

I should also mention that the token browser for this module does not list all of the argument tokens. The attached pic has a full list.

drunken monkey’s picture

Category: Bug report » Feature request
Status: Active » Needs review
FileSize
624 bytes

This would be rather hard to fix in this form, especially in this module, I think. If anything, this should be fixed in the Views module: when resolving a token for [view:url:*], and arguments are set, the arguments could automatically be substituted for their corresponding path parts.
However, this would significantly complicate the code, and probably also not be in the itnerest of everyone using these tokens, so I don't think such a patch would have a chance to be committed.

What would be possible, however, is just letting the admin use the special Views-style pseudo-tokens for arguments (i.e., %1/!1, %2/!2, etc.) to achieve exactly the effect you want – including the argument values (with their original spaces) in the Metatags.

A patch is attached, I opted to use hook_metatag_pattern_alter() to implement this – it could of course also just be added to metatag_views_page_alter() with a loop, but I guessed this would be too inflexible? Or would the performance improvement be worth it?
Also, this could of course be made optional per view, if you want that. And maybe we should add this to the description somewhere.
But in principle the code works, at least for me.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs review » Needs work

So yeah, we need a per-View option for this.