0

I'm trying to make every taxonomy term page link direct to a pattern like this:

/viewpage?[term:vocabulary][]=[[term:tid]]

So, for example instead of material/bronze where bronze has term id 7, you'd have:

/viewpage?material[]=7

...and you'd go to a views page where the user could then turn off the materials filter and turn on other filters.

I've tried setting this pattern up using PathAuto at /admin/config/search/path/patterns, which does the opposite of what I want: while it does make links to a taxonomy page point to URLs that look like viewpage?material[]=7, it then intercepts these and sends them to the default taxonomy term page, breaking the exposed filters!

I've tried using Global Redirect, but it doesn't seem able to apply patterns, it seems I'd need to enter the redirects by hand which isn't sustainable.

Redirect Tokens module looks to be designed to do what I want, and even has an example very similar to my case but with users not taxonomy and facets not exposed filters, but on closer inspection a) it only accepts tokens in the "from" field not "to" and b) it only works with global tokens like current user.

I've figured out that it's potentially possible using cTools Page Manager:

  • Enable and edit the Taxonomy View page
  • Set it the HTTP Response Code variant
  • Select 301 redirect then input the new URL...

...but I'm not sure how to inject the [tid] into the new URL pattern. The help text says "You may use keyword substitutions from contexts" but there doesn't seem to be any way to view or edit contexts for a page override.

How can I bulk redirect all current and future URLs of taxonomy term pages to this exposed filter view?

0

After some trial and error and guesswork I've got it working using Page Manger (part of the cTools module):

  1. Under Structure > Pages, Enable and Edit the Taxonomy View page - if there isn't one, you might need the Page Manager Existing Pages module
  2. Create a "HTTP Response Code" variant
  3. Select "301 Redirect"
  4. For the default pattern, enter something like:

    pagename?%term:vocabulary:machine-name[]=%term:tid

  5. Test this. There might be cases where the field name stub used in the exposed filter doesn't match the actual vocabulary machine-name and where editing this in Views isn't a good option. For example, I had one field named "colours" not matching its underlying vocabulary "colour". You might also have exposed filters using strings like field_fieldname_tid which you might have reasons to not change. If this happens:
    1. Go back to "Summary" in Page Manager for this override
    2. Click "Add new variant"
    3. Give it a sensible admin title (e.g. the vocabulary name) else you'll hit an error later on as it'll match the default name
    4. "HTTP response code" again, and tick "Selection rules"
    5. Choose an appropriate selection rule (probably, "Taxonomy: Vocabulary", then tick the awkward vocabulary), continue
    6. Choose 301 redirect again, and enter the same pattern as before but with the token %term:vocabulary:machine-name replaced with the string used by the exposed filter, for example pagename?colours[]=%term:tid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.