Additional tokens for book url path

fgm - March 16, 2009 - 09:17
Project:Token
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review
Description

The bookpath token is currently built from the titles of the parent nodes in the book.

With pathauto, which is likely the most frequent use of this token, if the path to one (or more) of the parent nodes has been manually set, this means the book path components won't match a working path hierarchy even if the number of components is the renamed path is correct: backtracking to home by removing the last path component will leave the user at an invalid alias for that level.

However, if the aliases to each level in the book hierarchy were used to build the bookpath, this problem would not occur, as long as the forced aliases maintain the path logic (number of components, hierarchy consistency). Although "bookpath" is a builtin token of token module, I'm not sure whether this is really a pathauto or token issue.

#1

nirbhasa - November 7, 2009 - 16:14
Title:Bookpath does not necessarily reflect the actual book path» Additional tokens for book url path
Version:6.x-1.11» 6.x-1.x-dev
Category:bug report» task
Status:active» needs review

I am attaching a patch that adds 2 new tokens [bookurl] and [bookurl-raw] that generate the combined url path of all parents in the node's book hierarchy.

In order to do this, I changed the _menu_titles function to a more general _menu_info, allowing me to use it to return both the titles and the url aliases of the parents in the hierarchy.

Along the way 2 issues were fixed, that also affected the existing [bookpath] and [bookpath-raw] tokens

1) If the top book is the site frontpage, we shouldn't put its url/title in the trail.

2) For book paths, we don't include the current node's title/path the array in the trail. However _menu_info (formerly _menu_titles) function doesn't return current nodes title/path if node is unpublished, so in that case there is no need to remove anything.

However I have one last problem: the function book_token_values returns the proper token (pathA/pathB/pathC, say), but somewhere later, all the slashes are taken out and I am left with pathApathBpathC as my alias. This doesnt happen with the [bookpath] and [bookpath-raw] tokens, and I'm a little mystified as to what's so different about my tokens. If someone could help me with this, that would be fantastic!

AttachmentSize
token_bookurl.patch 5.47 KB
 
 

Drupal is a registered trademark of Dries Buytaert.