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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

greggles’s picture

Project: Pathauto » Token
Version: 5.x-2.0 » 5.x-1.x-dev

I'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.

alansz’s picture

In 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

greggles’s picture

Status: Active » Needs review

Thanks for the investigation alansz - can you try out this patch?

greggles’s picture

I forgot the patch somehow...

Can folks please test this?

greggles’s picture

No, the patch from #4 doesn't work :/

Here's one that does.

greggles’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.