D6' taxonomy/nodeapi hasn't stopped being a bitch. And the #25/#27 fix from #420548: Problems with URL alias with pathauto and HS' [save-lineage-termpath] token to work around the bitchiness, hasn't been committed yet.
(The particular problem I had is with mass-generating node aliases from pathauto. It must be doing something simple like node_load -> hook_token_values -> adjust path -> node_save.. but in that flow, $node->taxonomy is a simple array of tids, which the current code doesn't work with.
So if you (re)generate your aliases, all your [save-lineage-termpath] paths are toast.)
I dusted off mauritsl's patch (in #25) which was based on Stupidscript's work (in #27) and added a tiny fix. Props to them.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1073858-6.patch | 2.43 KB | roderik |
| hs-lineage-token.patch | 1.86 KB | roderik |
Comments
Comment #1
wim leersThis first needs some positive reviews before it can go in :)
Comment #2
divbox commentedi've added this patch and can confirm it works, but only when i set the node path url alias to this
using the previous patch in 25 here #420548: Problems with URL alias with pathauto and HS' [save-lineage-termpath] token worked when I set the node path url alias to this:
EDIT: I spoke too soon. It does not work 100% yet. I am testing some options out and will report back.
Comment #3
roderik@divbox: I'm curious to the options you're testing out - especially since this is a pretty generic fix. The only way I can see this going wrong is when $node->taxonomy doesn't actually contain the terms you want, in the first place.
Do you have a multilanguage site, by any chance?
I was just hit by a bug in i18sync.module that eats up taxonomy terms of (translated) nodes...
Comment #4
roderikBulk alias generation with pathauto v2.x does not work on sites with i18ntaxonomy enabled. This is not HS' problem. So anyone testing the above with Pathauto 2.x should first apply #1125938: i18ntaxonomy_db_rewrite_sql() should back off on batch operations
Comment #5
divbox commented@roderik. i am not using multilanguage on the site. and node->taxonomy is populated.
when i use "[save-lineage-termpath]" it's blank, and when i use [save-lineage-termpath-raw:vid], i get "[save-lineage-termpath-raw%3Avid]" in the url, and when I use "[save-lineage-termpath-raw:6]" i can't even submit the url alias form as it says "invalid token". 6 is a valid vocabulary ID.
I am using content taxonomy if that matters.
Comment #6
roderikThere's separate but related issues here.
I tested your [save-lineage-termpath-raw:6] claim and
- fixed it - in a separate patch: see #1137056: Pathauto >= 1.4 admin screen disallows [save-lineage-termpath-raw:vid] token
- while testing, found what is probably your issue: the token only works when you have "Save term lineage" set in the vocabulary settings. (As opposed to "Save only the deepest term".) That fix I included in the below patch.
@divbox: you can unapply the first patch and reapply this one -- or apply only the 3rd hunk of the below, in some way. It'd be great if we can get this moved in.
Comment #7
divbox commented@roderick.
1) i backed out the initial patch and then first applied the patch for the :vid token. this removed the :vid option from the replacement patterns on the pathauto page. looking at the patch, it looks like it will only show the :vid option if it is available. so maybe this is part of the issue for me?
2) i then applied your updated patch in # 6. i selected [save-lineage-termpath-raw] on pathauto page, but i am still not getting the terms in the url. just title. [save-lineage-termpath] is just blank.
i do have it setup to "save term lineage", but still no joy.
so i started to disable things. i was also running the taxonomy manager module. i disabled this, but that also did not help. but this made me click into the taxonomy page through the normal drupal method (admin/content/taxonomy) and i noticed this "Use the Hierarchical Select form element for this vocabulary." and the box was not checked. so i checked it and path's are now working as they should w/ [save-lineage-termpath-raw]
so this may have been my problem all along i guess. i feel kinda dumb for not seeing this in first place. i think i probably did, but did not think it would help/be necessary. i should click more :)
i'm going to back out the 2 patches and try again w/ just the HS module and then apply patches back into see if they are indeed needed for my situation. i will report back my findings.
thanks for your help and patience!
div
Comment #8
jawcw commented@roderick
The patch in #6 worked for me!! You are a god.
Thank you.
jaw
Comment #9
alanpeart commentedThought you might like to know that this patch has saved my sanity late at night during a data migration for a client from one drupal site to another. Thanks!
EDIT: I spoke too soon. The fix worked intermittently (some URLs were updated correctly, and others weren't).
I've tried to read up on the rest of the threads surrounding this issue and couldn't make head or tail of all the different patches, fixes and recommendations. There certainly doesn't seem to be a consistent solution out there, and these issue threads are months old, and nobody wants to work on D6 any more anyway, so I'm going to treat the HS taxonomy tokens as unusable and find a workaround for this site.
Comment #10
gooddesignusa commentedI'm was using [save-lineage-termpath-raw]/[title-raw] for my alias and was having some issues with the "Automatic alias" checkbox while editing a node. It kept unchecking itself. Patch in #6 fixed that. Thank you
Comment #11
halloffame commentedPatch at #6 worked for me. Thanks a bunch!
Comment #12
benmirkhah commentedPatch #6 in combination with the fix for issue #1137056 worked for me, thank you!
Comment #13
goldTidying up the issue queue. The 6.x version is no longer supported. Only reopen this if it also applies to the 7.x.