2

CONDENSED SUMMARY OF ISSUE: I have a view with a path of /taxonomy/term/%/something that responds to a URL alias of /spec/ID/ so entering /Spec/ID or /Spec/ID/Something displays what is in the View. If I clone the View and change the paths from /taxonomy/term/%/something to /Spec/%/Something entering a URL of /specs/ID will no longer display the view.

ADDITIONAL INFO: I have created a View (D7 Views3) with several pages each with the path /taxonomy/term/%/sub-category where subcategory is a label for a subgroup of content for the specified term. A filter in each page limits the content to match the subcategory label.

I have created an alias for a vocabulary /specs/[term:field_specno]. The field, attached to the term, provides a unique ID for the terms relating to a client's set of standards.

If I enter a URL for /specs/term1, the view will display the correct content for term1 on a page display, with operating Menu Tabs I have defined for each page in the view. It works great except that if I select another Menu Tab, the URL changes to taxonomy/term/%/subcategory format used in the view. This would be confusing if a user uses the URL and gets the cryptic tid instead of his ID system. It I clone the view and change the paths to spec/[term:field_specno]/sub-categories, the view no longer displays the pages and tabs correctly.

Is there a fundamental problem in Drupal doing this or have I screwed up somehow? Has anyone done something similar successfully?

2
  • There are to many parts of the problem, I can't quite grasp where things to wrong for you. Can you try to shorten down the question? :)
    – Letharion
    Jan 27, 2012 at 22:13
  • You're right, I boiled it down in the added first paragraph.
    – Ashlar
    Jan 27, 2012 at 22:41

4 Answers 4

1

It could be, that I'm still having difficulties understanding your question, but I have no idea why you would expect that to work?

/path/to/%term contains an argument, and as such there is essentially an infinite number of variations that could "fit" into that path. A path alias "/pageone" to "/path/to/aterm", does not match "/path/to/otherterm", nor any other path in the system.

Each path alias must point to a specific path, and there is to my knowledge no way to automatically "Create all possible path-aliases to for a path /path/with/%arg". There is a feature request for such a tool though.

3
  • OK let me try and clarify. My views are defined with % wildcards for the tid in View1-/Taxonomy/term/% or for a custom ID (CID) held in a field for View2-specs/% path. Both work in preview, the only difference between them is the path and the contextual filter setting. If I enable View1 and enter a URL using the path alias for the term/specs/CID, View1 works. If I disable view1 and enable view2 and enter the same URL, View2 fails.
    – Ashlar
    Jan 27, 2012 at 23:59
  • If I "get it" now, that does sound like it should work on.
    – Letharion
    Jan 28, 2012 at 15:34
  • Letharion +1 and Check. Letharion & I discussed this in a chat to clarify the information and I will explain the results as an answer.
    – Ashlar
    Jan 28, 2012 at 19:31
1

Letharion's answer:

Drupal translates the URL alias to the actual URL very early in the request sequence so it cannot find the View defined with an alias path.

Path Auto creates an alias for a URL and Drupal translates the alias into its true path and then executes the URL action. In the example in the question, the URL contains /specs/ID which Drupal changes to /taxonomy/term/[tid]. Since the view path is defined as /taxonomy/term/%, the view is called and works as designed. In the second case, the view path has been changed to /specs/% and Drupal, having already changed the URL request from /specs/[ID] to taxonomy/term/[tid] does not associate the view definition with the URL request, so the View is never called.

My reason for attempting this was so that the alias URL would be visible after the view is called and a user could use the URL alias to change to another view in addition to a special menu. Unfortunately, when the view is called, the url for the view is displayed (/taxonomy/term/[tid]). I do not see any work around for this at this time.

1

For those, who still searching issue... Creating path alias for your term-related view seems good idea. You can do it in hook_node_presave().

For Example:

I have page view with path node/%/tours and menu tab "Tours" for node 123 i have alias: node/123 -> country/Greece. When opening country/Greece, we can see "Tours" tab with node/123/tours link. After adding alias node/123/tours -> country/Greece/tours tab link will be country/Greece/tours

Just found: Extended path aliases module.

0

So the way I understand this questions is such:

You created a view, with a path that has an argument. Then you created aliases for each variance?

Like, if my View path was /animals/% you would just make aliases for /animals/cats to just /cats, /animals/dogs to /dogs.

Then you went and changed the view path from /animals/% to /creatures/% and you wonder why your aliases no longer work?

If that's the case it's because aliases are static and don't know when the thing they are aliasing changes. You'd have to go back and correct your aliases so they now point to /creatures/% since that's now the path your view is operating on as /animals/% no longer exists.

1
  • No, I did not create a variance for each view possibility. Using your example, 'animals' is a vocabulary and dogs & cats are terms. The alias for the term 'dog' may be animals/dog, but the actual path is taxonomy/term/a-term-number-for-dog. My answer on this question should help clarify what I was doing and why it doesn't work in Drupal.
    – Ashlar
    Jan 28, 2012 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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