Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I've set up hierarchical select with one of my vocabularies and have set "Save term lineage". The terms in that vocab look like this:
- Blue
- - DVD
- - CD
What I want is an URL like this:
blah.com/blue/dvd/node-title
With a pathauto setting of [termpath-raw]/[title-raw], I get:
blah.com/blue/node-title
With a pathauto setting of [save-lineage-termpath-raw]/[title-raw], I get:
blah.com/blue-dvd/node-title
I am lost! What do I need to do to get all my parent and children terms into my URL? Thanks!
Comments
Comment #1
Wim LeersHm, I was under the impression that [save-lineage-termpath] worked similary to just [termpath], i.e. that each item in the lineage would be separated by slashes, as you were expecting. I guess I'm remembering that incorrectly.
Just to be sure that this works with [termpath], please switch over to [termpath] for a sec, ignore the incorrect order, and let me know if there indeed slashes are used.
If it's got the same problem, then I'm afraid this is a pathauto limitation. We could of course hack the code a little bit to make it work for you.
Comment #2
leenwebb CreditAttribution: leenwebb commentedHuh... this is totally weird. I tried this like FIVE times yesterday and got the results I posted above. But I just changed to [termpath] and it was fine and then changed to [save-lineage-termpath] and now it is also fine. So, uhhh... Fixed? By your psychic powers? Sweet!
Comment #3
leenwebb CreditAttribution: leenwebb commentedCuriouser and curiouser. It worked, but now it doesn't*, and I haven't changed any settings. OK, so, if I use
[termpath]/[title-raw], I get:
blah.com/blue/node-title
With no children. Just the parent term.
With [save-lineage-termpath-raw]/[title-raw], I get:
blah.com/blue-clothing-shirt/node-title
(Instead of blue/clothing/shirt/title)
Where might I go in Pathauto to make those - into /? In the general settings it uses - but I think that setting is for spaces, not separate terms.
* As in: 10 nodes that I put in had the correct paths, but the 11th and 12th don't.
Comment #4
Wim Leers*huh* :O Maybe you've got some module interfering with pathauto then? This all sounds very weird.
Your pathauto settings are fine, there's nothing you can change. The hacks I was mentioning were in hs_taxonomy.
However, I've found the cause:
That last line is the cause of course. Just change that one line for a second and it'll work as expected.
I guess I should change that to something like:
Then you could set the hs_taxonomy_separator variable and be done with it.
Comment #5
leenwebb CreditAttribution: leenwebb commentedUgh, this is SO weird.
A) I changed that - to a / in the code but it still gives me - in the URL. I even cleared cache (I have no idea if that would do anything, but I view cache as some sort of voodoo so I figured it couldn't hurt).
B) I deleted all the content aliases, then asked Pathauto to regenerate them. Using [save-lineage-termpath-raw]/[title-raw], all of the re-generated aliases had NO TERMS at all! Just straight-up blah.com/node-title. (Which is what I have set as the default "if nothing else is specified" pathauto setting.)
C) I deleted all of them again and re-generated using [termpath-raw]/[title-raw]. This time I get the top-most parent for all of them, like blah.com/blue/node-title. But ONE of them (just one!) has the proper URL of blah.com/blue/cd/name-of-cd.
WTF drupal: Are you trying to make me cry?
Comment #6
Wim LeersA) The second parameter of variable_get() is the default value, if you've set "-" through the pathauto settings, it'll still use that.
B) WTF?
C) Bah.
Just make the change I mentioned in A and hope for no weirdness this time …
Comment #7
leenwebb CreditAttribution: leenwebb commentedSUCCESS! The low-tech hackity change to
$separator = '/';
does the trick.(FWIW, using pathauto's bulk alias feature to regenerate these aliases is totally wack. (B) above is very consistent for me -- they are generated as blah.com/node-title with no terms at all. But then if I go into the node edit the path box is empty, and on saving it will generate the (now-correct) full-of-terms URL. Doesn't matter for the site I'm setting up, as I only have 12 nodes so far. But... weird.)
Comment #8
vthirteen CreditAttribution: vthirteen commentedWim Leers said:
where am i supposed to set the hs_taxonomy_separator variable?
Comment #9
vthirteen CreditAttribution: vthirteen commented$separator = '/';
it doesn't work for me... the slash gets stripped and the final URL is something like /term1term2/nodetitle
Comment #10
Wim Leers@vthirteen: you should add the slash to the allowed characters then.
Comment #11
Wim LeersImplemented, documented, patches attached and committed:
- D6: http://drupal.org/cvs?commit=244596
- D5: http://drupal.org/cvs?commit=244598
Comment #13
ryantollefson CreditAttribution: ryantollefson commentedI'm getting the same results as vthirteen.
I'm running 6.x-3.x-dev and when I try to use: [save-lineage-termpath-raw:5] I am getting the "-" instead of a "/" as a separator. I tried changing the $separator = '/'; as suggested, but like vthirteen I then get /term1term2/ instead of /term1/term2/. I also tried to add the '/' as an allowed character in pathauto, but that didn't seem to make a difference.
Has anyone confirmed that this works with a "/"? Perhaps I am missing something simple here? Thanks in advance.
Comment #14
Uersu CreditAttribution: Uersu commentedThe current readme.txt says: "You can override this by setting the hs_taxonomy_separator
variable."
Please, also mention (or add a reference) how/where I can add/set the variable 'hs_taxonomy_separator'. I know that there is a 'variable', but I am not sure how to easily add a variable to this table without having to write a module.
Or do I completely misunderstand something?
Comment #15
-enzo- CreditAttribution: -enzo- commentedHello Guys
I did the following small module to set the hs_taxonomy_separator
The problem is I want to use "/" as separator, but doesn't matter want separator I use always is removed :S
Any idea.
enzo
Comment #16
pupp CreditAttribution: pupp commentedAs bad as this sounds, i simply commented out that line in hs_taxonomy and added $separator = '/'; it works and i've already wasted too much time on this. Hopefully this gets fixed.