It would be great if this module can be modified so its functionality would extend to taxonomy terms.
Upon adding a term, pathauto would take the term name, and create an alias from it for that term path.
It could also be done in a hierarchy manner. For example, if term/123 is actually News -> International -> Asia, then it would create news/international/asia as the alias for that term.
Thanks for such a great module.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | pathauto_0.patch | 9.55 KB | jdmquin |
Comments
Comment #1
mikeryanInteresting thought - so, there should be another configurable pattern to use for taxonomy terms (using just the [vocab], [catpath], and [cat] placeholders)?
Comment #2
jdmquin commentedI'm working on a patch to pathauto that does this right now. It has the following features:
The only issue I have run into is if you have multiple vocabularies assigned to a node type the categories appear in order of the term weight regardless of the vocabulary weight. An example:
Story Type, weight 0
News, weight 0
Action Alerts, weight 1
Etc
Topics, weight 2
Education, weight 0
Etc.
A node with Story Type of News and Topic of Education has Education as the first term. Unfortunately this is a drupal issue. A work around is to set the term weights for all terms that a node type uses. I.e. change News to -5 and Action Alerts to -4, etc, so they show up above Topic terms.
I should have the patch done in the next couple of days, April 13, 2005 by the latest.
Thanks
JJ
Again, great module!
Comment #3
jdmquin commentedThe patch is complete. I was unable to add a path textfield to the add/edit term page. I did not realize that hook_taxonomy did not have a form pre or form post operation. Anyway the patch is attached. It allows you to auto create paths for categories.
Thanks
JJ
Comment #4
jdmquin commentedBy the way. This patch is based on the latest CVS pathauto.module. Posted yesterday.
Thanks
JJ
Comment #5
tostinni commentedHi,
Thanks for your patch (maybe you need to switch Status to patch).
For my site, I'm using taxonomy, but the navigation is going through taxonomy_menu.
Can you extend your patch to taxonomy_menu ? I'm looking at this moment, if I'm able to set up this feature.
PS : you need to update your patch, a new CVS was rolled out.
Comment #6
kbahey commentedSetting the status to patch. Hope it gets picked up and rolled into the pathauto as a standard feature.
Re: taxonomy menu, I think it will use whatever aliases are setup for taxonomy, regardless of whether these aliases are created manually or using pathauto.
I have a module, called site menu that displays a taxonomy based navigation menu block and a sitemap page. It always displays the taxonomy aliases, and not the taxonomy/term/123 thing.
So, I don't think that a change is needed specifically for taxonomy menu.
Comment #7
tostinni commentedLine 188 your module make a call to
comment_num_allwithout previously checking if comment module was available.So when you access Site map you get a general error.
Comment #8
tostinni commentedUps sorry for the last comment, it was diriged at your other module :D
Your sitemenu module is great, but I'd rather use taxonomy_menu because it provide me collapsible menu that I need. That's why I keep using it. Also it allow me to get various block for my vocabularies and so I can display them regarding of my users roles (patch I'm doing).
Ok it's not the point here ;)
So taxonomy_menu use a little special kind of link, that are not like taxonomy's (I guess this is to allow collapsible menu).
So they are like this :
taxonomy_menu/1/2/3
1 is your vocabulary, 2 is a child of 1, and 3 is the child of 2 etc...
I'm trying to analyze taxonomy_menu to get my patch to add, but, it begins to be a little off road from pathauto goals... I'm not sure they would add all kind of aliases generated by each module...
Comment #9
mikeryanKhalid, I'm working on integrating your taxonomy patch now. There's a pretty significant problem, at least with Drupal 4.6 (which is what I'm developing on now) - [catpath] doesn't work on insert, because the taxonomy module doesn't populate term_hierarchy until after calling the hook (thus, taxonomy_get_parents_all() only returns the new term itself, not its ancestors). Don't ask me why the hook behaves like that...
Couple of other notes:
I'm renaming [catname] to [cat] (consistency with node patterns).
I'm also renaming [cid] to [tid]. I understand the mnemonic advantage (category id), but the discrepancy with Drupal internals will cause problems with people at the developer level (and I think this is a sophisticated enough feature that it would largely be used by those people). Plus, I figure any day now someone will request automatic aliases for comments:-), I'll need to save [cid] for that...
_pathauto_generate_cat_alias() should not do anything in the update case if there's already an alias for the term - administrators may get an unhappy surprise if existing links break when they rename a term (especially since, with no way to put the alias into the term edit form, they would have no way to prevent it).
I'll take care of the last issue, once I figure out what to do about the [catpath] issue (tell people to update the term after inserting it?) I'll commit this functionality to CVS.
Thanks for all your work.
Comment #10
kbahey commentedMike.
Thanks for responding to this, and accepting the patch.
I can't take credit for jdmquin's work. I came with the idea, he did the patch.
Regarding
How about doing it via a cron hook? That should work, but there will be a time delay for it, depending on how frequently the site admin configured it.
Or maybe restrict catpath for taxonomies? Kind of inconsistent.
Or maybe submit a patch to taxonomy module to fix its behavior?
I dunno, needs some more thought.
Comment #11
ramdak5000@www.drupal.org commentedI am a non-techincal person, but does this patch essentially do what Jeremy Epstein explains in detail here?
http://www.greenash.net.au/posts/thoughts/hierarchical_url_aliasing
I am also pleasantly surprised because this is exactly the approach I suggested to Jeremy for his proposed module for hierarchical aliasing.
Two things on my wish list for this patch:
1.) Can this be used with 4.5?
2.) Index pages for vocabularies?
Currently, only terms have their own pages. I agree this may not be the province of the pathauto module, but it would be great to have a page generated for each vocabulary.
Comment #12
tostinni commentedAnd what about my little suggestion around taxonomy_menu ? I won't have time to work on it, but I will reconsider it soon.
I'm waiting for the next CVS version of pathauto.
Comment #13
mikeryanBusy day on the thread...
Sorry jdmquin for misdirecting credit, I scrolled up too far looking for the name to credit:-).
Re: thoughts about fixing [catpath] for term aliases... Can't say I'm fond of the cron hook idea, it would be odd to have aliases be immediately available except for term aliases that use [catpath]. And I hate when contrib modules depend on patching core... Ideally taxonomy.module can be "fixed" to call the hook after the term has been entirely set up, but it seems such an obvious thing to do that I can't imagine it working this way without a specific reason (such as something depending on this to manipulate the hierarchy before it's set in stone). I suppose I should propose moving the hook, or adding an after-the-fact hook, and see what the core developers say (of course, if anything comes of it, we wouldn't see it before Drupal 4.7). Right now all I can think of is telling users to make an empty edit to the term to recreate the alias with the full path...
Re: Jeremy's aliasing implementation - I replied over on his site, I do believe pathauto (with a little more work) can do everything he wants.
Re: 4.5 - So far it's compatible with 4.5, as far as I know. When I went to port the original 4.5 version to 4.6, no changes were necessary, and I don't believe I've done anything yet to break 4.5. I'm using 4.6 now on my development system, though, and don't have time to test on both, so buyer beware...
Re: Index pages for taxonomies - this has been suggested for nodes, and I'd like to do it. Because the code would differ between 4.5 and 4.6, and I don't have the time to maintain multiple versions in parallel, I'm planning on implementing this only for 4.6 and above. I'll do this after catching up on all the changes I'd like to get into the 4.5 version of pathauto.
Re: taxonomy_menu - I don't think hard-coding support for specific contrib modules belongs in pathauto. But I'm thinking about adding hooks so other modules could add their own placeholders to the pattern language...
Thanks for all the comments! One request - we've gotten well off track, from this point on let's stick to taxonomy term aliasing here, please open a new issue for anything else you'd like to discuss regarding pathauto.
Comment #14
mikeryanForgot to announce it here, but the taxonomy patch has been incorporated into pathauto (both 4.5 and 4.6 versions). I did find an answer to the [catpath] problem - although the hierarchy table hasn't been updated when the hook is called, the parent is available in the passed object.
Comment #15
kbahey commentedA bit thank you!
I just tested it and it works great.
This module is really a great help.
Comment #16
mikeryan