I am trying to use pathauto to generate custom paths based on the top parent of a book. I have tried several different options including [menupath-raw], [book-raw] , and many others as the pattern for Book page paths. When I create a sub-page of a book, they all fail silently, except for [nid] and [title-raw].

Have I made an error in the pathauto admin or is this a bug?

Comments

mikeryan’s picture

Project: Pathauto » Token
Version: 6.x-1.0 » 6.x-1.10
Component: Miscellaneous » Code
Status: Active » Closed (duplicate)

Duplicate of token issue http://drupal.org/node/223458, fixed in the 6.x-1.x-dev release.

greggles’s picture

Title: [bookpathalias] and other node variables fail » [bookpathalias] not replaced
Project: Token » Pathauto
Version: 6.x-1.10 » 6.x-1.x-dev
Status: Closed (duplicate) » Active

Actually, bookpathalias is the responsibility of Pathauto so we need to fix that.

greggles’s picture

Status: Active » Needs review
StatusFileSize
new2.27 KB

And here's a patch which does this.

I wish there were an API for getting the menu data but all of the menu API functions I could find expected me to have the menu router or path and then it would return the other data.

I also re-ordered the code so that the book stuff is separated from the term/cat stuff, but if we do that then maybe we need to do just that re-organization for 5.x as well.

Freso’s picture

Status: Needs review » Reviewed & tested by the community

Default node pattern: [title-raw]
Book page pattern: [bookpathalias]/[title-raw]

Making a "book page" on the top level triggers a couple of notices:

  • notice: Undefined offset: 0 in /srv/http/localhost/htdocs/drupal6/sites/all/modules/token/token_node.inc on line 228.
  • notice: Undefined offset: 0 in /srv/http/localhost/htdocs/drupal6/sites/all/modules/token/token_node.inc on line 237.
  • notice: Undefined property: stdClass::$parent in /srv/http/localhost/htdocs/drupal6/sites/all/modules/pathauto/pathauto.module on line 107.

The last one goes away with the patch applied.

Making a node "Super" as the top-level book entry creates a node with the alias "super". Pre-patch, making a node "Sub" as a child node of "Super" creates alias "sub". Post-patch, making child node "Sub 2" creates the alias "super/sub-2".

Marking RTBC.

Freso’s picture

Eh. Oh, one more thing though. The SQL query is surrounding by superfluous double quotes. The attached patch is the one I tested - it is basically identical to the one in #13, it's just got a pair of double quotes changed to a pair of single quotes. :)

Freso’s picture

Or... not attached. Let's try again.

Freso’s picture

That bug is really annoying.

Freso’s picture

Freso’s picture

Freso’s picture

Bloody hell. I give up.

I changed
+ $parent_node = db_result(db_query("SELECT link_path FROM {menu_links} WHERE mlid = %d", $object->book["p$i"]));
to
+ $parent_node = db_result(db_query('SELECT link_path FROM {menu_links} WHERE mlid = %d', $object->book["p$i"]));

greggles’s picture

Title: [bookpathalias] not replaced » bookpathalias token broken
Version: 6.x-1.x-dev » 5.x-2.x-dev
Assigned: Unassigned » greggles
Status: Reviewed & tested by the community » Patch (to be ported)
StatusFileSize
new2.03 KB

Fixed. Now to make the code structures a little more consistent...

greggles’s picture

Status: Patch (to be ported) » Fixed

I didn't commit that last patch...if this lack of similarity becomes a problem in the future we can worry about it then.

greggles’s picture

Well, now I accidentally committed the patch from #11 as part of http://drupal.org/cvs?commit=122748

So, yay synchronization!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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