Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I use this pattern for book urls:
book/[book-raw]/[title-raw]
Works great for book pages, except the top-level page.
The top-level page of a collaborative book which has no parent gets me a url like this:
http://community.pennmush.org/book/%5Bbook-raw%5D/enough-be-dangerous-co...
Note the literal "[book-raw]", as there's no parent to replace into that token.
Is there a way I should be dealing with this that's prettier, or should that token somehow resolve itself into an empty string or something so that it doesn't appear in the URL?
Thanks!
- Alan
Comment | File | Size | Author |
---|---|---|---|
#5 | 205799_token_book_raw_not_defaulted_5.patch | 1.19 KB | greggles |
#4 | 205799_token_book_raw_not_defaulted.patch | 1.12 KB | greggles |
Comments
Comment #1
gregglesI'd say it's a bug in token module, though looking at the code it seems like it should be working...
If you look in token_node.inc at book_token_values and particularly at the " if ($node->parent) {" and see what is happening in there that might find the solution. I'll try to look at this in the coming week or so but I can't just now.
Comment #2
alansz CreditAttribution: alansz commentedIn token_node.inc in book_token_values, the book-raw token isn't explicitly assigned to empty string in this case (book, book_id, bookpath, and bookpath-raw are, however).
So either I should be using bookpath-raw (probably best) or book-raw should also be getting set to '' in the else clause there.
Thanks for the pointer. If you consider it a bug in token, and you're the maintainer of that as well, now you know. If not, maybe you can pass it upstream?
Best, Alan
Comment #3
gregglesThanks for the investigation alansz - can you try out this patch?
Comment #4
gregglesI forgot the patch somehow...
Can folks please test this?
Comment #5
gregglesNo, the patch from #4 doesn't work :/
Here's one that does.
Comment #6
gregglesFixed in 6.x - http://drupal.org/cvs?commit=126142
and 5.x - http://drupal.org/cvs?commit=126141
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.