If you want to change the path alias for a term, you have to first find the term, then find it's tid (not always possible in D6 with pathauto, especially if your RSS feeds are aliased), then go into the path admin interface, find the alias, then edit it. This takes ages.
We should add a path alias form to the taxonomy term edit screen if path module is enabled - same as is currently done for nodes.
| Comment | File | Size | Author |
|---|---|---|---|
| #49 | taxonomy term edit path.png | 66.17 KB | joachim |
| #45 | taxonomy_aliases_9.patch | 3.7 KB | Bojhan |
| #42 | taxonomy_aliases_8.patch | 3.54 KB | tylor |
| #35 | taxonomy_aliases_7.patch | 3.35 KB | tylor |
| #33 | taxonomy_aliases_6.patch | 3.35 KB | tylor |
Comments
Comment #1
akahn commentedI think this is a cool idea and I'd like to help out on it.
I'd also like to link to #475968: Path helper interface for menu module and quote from merlinofchaos:
Comment #2
elvis2 commented@catch, a few questions...
1) should this feature be available on both when adding/editing a node and term (node/1/edit and taxonomy/term/1/edit)?
2) Regarding UI when on the node form, where should the term path option show up? Under the "tag" field, or near the bottom, below the "URL path settings" field?
Comment #3
tylor commentedHere's a patch that should provide a good start to getting this in. Basically I added the URL Path Settings fieldset in the same way that it appears on the node edit form but for the term edit form.
Things I'm unhappy about in this patch:
- please test language support - this is untested and I don't know if $term->language is ever set.
- do we really want $term->path loaded with every taxonomy term (performance hit?). Could maybe handle this just on the term validation and submission instead. From API page for hook_taxonomy_term_load():
- the hook_form_alter() check for the taxonomy form could be better. I'm not happy with looking at empty($form['confirm']) to see if we are on the delete confirmation page.
Also found that the hook triggers for _update and _insert in taxonomy.module were backwards. Should this be broken into its own issue? To work correctly, this needs to be fixed.
This is my first biggish patch for core! :)
Comment #4
tylor commentedComment #5
elvis2 commentedSorry, I didn't know someone else was working on this... Here is my patch... I used as much path.module functions as possible...
Comment #7
elvis2 commentedresubmitting
Comment #8
tylor commentedTrying to keep the momentum up for this issue. Here are screenshots from the term edit form for the patches in #3 and #7.
Comment #9
Bojhan commentedWe probally want it expanded by default? Or atleast don't do a summary in the fieldset, its not something we want to pursue in drupal.
Comment #10
dries commentedI'm a big fan of this patch.
For me, it doesn't have to be in a fieldset so I'd be OK with getting rid of the fieldset and always showing the option (when path module is enabled).
The patch has various coding style issues though. It needs more work.
Comment #11
Bojhan commentedWrong image.
Comment #12
psicomante commentedtrying to fix coding style issues
Comment #13
psicomante commentedfixed another indentation issue.
Comment #14
dries commentedQuick 2 minute review:
- There are two spaces between: "term url".
- In user output, we need to write URL instead of url.
- Code comments need to start with a capital letter and end in a point.
- ...
Comment #15
Bojhan commentedFixed
- Term url
- User output
- Some of the code comments
Looking at the comments it seems this patch needs finishing off.
Comment #16
catchWhile taxonomy module is optional, I think path module should hook_form_alter() itself here, see #476294: Add path alias to user edit. Saves module_exists() and module_invoke() calls.
Comment #17
tylor commentedThis is a reroll of my patch from #3 with the fieldset removed. This patch moves all of the code into path.module where it should be easier to maintain. Reposting in reply to #16 by catch.
Additionally it also fixes the hooks for hook_taxonomy_term_update() and hook_taxonomy_term_insert() in taxonomy.module which seem to be backwards.
Comment #18
tylor commentedSmall code style fixes from #17. Couple places where spaces were used instead of tabs.
Comment #19
catchCouple more things:
We usually try to avoid nested ternaries like this, better to initialize $path.
This could use hook_form_FORM_ID_alter().
Comment #20
tylor commentedHere's an update to address those issues. The ternary wasn't nested but for clarity I've broken those out into variables in both path_node_update() and path_taxonomy_term_update().
I've switched to path_form_taxonomy_form_term_alter() for the form alter.
Comment #22
chx commentedOnce I wanted to have a tab on every page to do path aliasing.
Comment #23
tylor commentedLast patch failed because of test bot. Checked out a fresh copy of head and got the same errors, seems something weird was committed.
Comment #24
elvis2 commentedWe have to decide which direction we need to go. Patch #20 code is mostly in path.module. Patch #7 is all done in taxonomy module files. Both patches attempt the same thing. Core devs, do you have a preference? Give us direction please. This thread has some rerolls for both patches...
Comment #25
dries commentedAdding the code to path module (per patch #20) is the proper direction.
Comment #26
elvis2 commented@Dries, thanks
Comment #27
damien tournoud commentedNice little patch.
^ is this code clean up really necessary here? Please avoid scope creep as much as possible, it makes patches more difficult to review.
^ This will be loaded each time a term is required. I don't believe it's necessary to load the alias each time.
^ As for as I know, Drupal Core doesn't support multilingual terms. You cannot do that ;)
^ You shouldn't call user_access() in low-level API functions. Access control needs to be done above (in the form itself).
^ There is a small code style error in the first line of the docblock.
^ Text fields cannot get collapsed ;)
^ This literally screams: "We need more tests". Of course, that's outside of the scope of this patch.
Comment #28
tylor commentedThanks for the review Damien, I think I've addressed all of the issues you've raised in this patch. For it to work correctly you will need to switch the taxonomy hooks as I've now left them out.
Comment #29
tylor commentedOpened a follow up issue to fix the taxonomy hooks: #537044: Taxonomy hooks backwards
Comment #30
dries commented- I committed #537044: Taxonomy hooks backwards.
- Missing space in
+ if(!empty($form['#term']['path'])) {.-
+ $path = $alias != 'taxonomy/term/' . $form['#term']['tid'] ? $alias : NULL;is weird and probably best written in multiple lines. The code is correct, it's just that I expected drupal_get_path_alias() to return NULL if no path alias was found. It would make this code cleaner. Best left for another issue.- Please add a code comment explaining why you populate
$form['identification']['path']['pid'].- It is not entirely clear why you implement hook_taxonomy_term_update() and hook_taxonomy_term_insert() instead of implementing a custom #submit callback. Any particular reason? I think you'd also want a #validate callback to see if the specified path already exists. The form has no error handling right now.
Comment #31
damien tournoud commentedThis is starting to get into shape!
I do agree with Dries that path_taxonomy_term_insert() and path_taxonomy_term_update() should be replaced by a new #submit handler. That's because if a module updates a term directly (by calling taxonomy_term_save), the path alias risk to be removed.
Comment #32
catchAlso agreed on the #submit handler, aliases are currently only related to paths and don't have a direct relationship with nodes/terms/users as such.
Comment #33
tylor commentedFollowed up on feedback from #30, fixed code style issues and moved to a submit handler with validation.
Comment #34
stborchertThis review is powered by Dreditor.
Very (very) minor bagatelle: one space missing in each of these lines.
Apart from that the code looks good to me.
Another question: now that we have some code to inject the path alias field into taxonomy forms and into user forms (#476294: Add path alias to user edit) do we want to "outsource" these functions to files like path.taxonomy.inc and path.user.inc?
Comment #35
tylor commentedWasn't too clear but I believe I have fixed the spacing issue, let me know if it needs any other changes.
Comment #36
tylor commentedComment #37
dries commentedThis looks good to me. Marking RTBC hoping to get a final review from someone else.
Comment #38
stborchertNo objections anymore and a big fat RTBC from me.
Comment #39
damien tournoud commentedI'm very sorry, but I don't get this chunk (but I am *very* tired):
Here $path is designed to be a default value. So this chunk should probably be (pseudo code):
Comment #40
tylor commentedHi Damien, when the taxonomy form is saved and a new term is added, the form is repopulated with the values from the last submission -- I also have found this confusing and maybe it should be opened as a separate issue? This snippet is to repopulate the path value in the form after the submission just like the rest of the values.
Comment #41
webchickWow! I like this patch very much!
Some minorish nit-picking and then this is good to go.
I agree with Damien that this could use some more/better comments. While what's there might be technically correct, it doesn't give me the broad-strokes overview of why it takes 10-12 lines of code to figure out the existing path alias.
Also, all comments should "Start with a capital and end with a period."
Where possible (like here) use double quotes around the string so you don't have to escape the quotes.
Double-check this, but I think in other simple queries in core, we don't break the query parameter to its own line.
This review is powered by Dreditor.
Comment #42
tylor commentedNit-pickiness is good! I'll see about opening a follow up issue to correct some of the mistakes that were inherited from the node path handling...
I've tried to clarify some of the comments, let me know if they still need some refinement or are still unclear. I couldn't find any docs on db_query() style for D7 yet but did see (and much prefer) the short version elsewhere.
Comment #43
catchThis looks better to me, please put line breaks before the inline comments here:
Comment #44
Bojhan commentedWorking on the last comment.
Comment #45
Bojhan commentedthere we go
Comment #46
webchickBack to needs review so bot can take another whack at it.
Comment #47
dries commentedCommitted to CVS HEAD. Thanks!
Comment #49
joachim commentedThis needs further work.
The path field comes after the buttons.
I'm guessing, though I'm not sure, that the original form has changed and this alteration of it has not followed pace.
Comment #50
dave reidWe already have this RTBC'd in #678590: Path alias link is below submit button on taxonomy term add.
Comment #52
imrubio22 commentedThis is exactly what I need...but for 6.x. Is there a patch for 6.x already? Thanks!