I love Pathauto, for me its an essential module for Drupal. I also like to use the Book module.

I am currently using: 6.12, CCK 6.x-2.3, Global Redirect 6.x-1.2, Path Redirect 6.x-1.0-beta3, Pathauto 6.x-2.x-dev (2009-May-22), Token 6.x-1.12, Views 6.x-3.x-dev (2009-Jun-05)

I have come across a ‘feature’that I don’t think is supposed to happen. I am not sure if the problem lies with the Pathauto, Token or Book modules.

Problem: A book page works with [menupathraw] token to create it’s URL Alias but a book outline does not seem to use the [menupathraw] token to create it’s URL Alias.

Example:
1) Enable the Book, Token and Pathauto modules.
2) Enter Automated Alias Settings - Node Path Settings - Pattern for all Book page paths: [menupath-raw].
3) Create a new menu called Main and place it on the left sidebar.
4) Create three new book pages. For the first page use Title: Book 1, Menu link Title : BP1 and Parent item . Do the same for the next two pages replacing ‘1’ with ‘2’ and then ‘3’ respectively.
5) Now we have the three menu links http://domain/bp1, http://domain/bp2, http://domain/bp3. That is good.
6) Go to the outline of BP3. Then in Book:. Click Add to Book Outline.
7) We still have the three menu links http://domain/bp1, http://domain/bp2, http://domain/bp3.
8) Go to http://domain/admin/build/menu-customize/menu-main. Drag BP2 to become a sub directory of BP1. Save configuration.
9) Edit BP2 and save it. The URL is now http://domain/bp1/bp2. That is good.
10) Go to http://domain/admin/build/menu-customize/menu-main. Drag BP3 to become a sub directory of BP1. Save configuration.
11) Edit BP3 and save it. The URL is now all of a sudden http://domain/book-page-3. That is the problem.

I would really like to have books as submenus but URL aliasing with Pathauto does not seem to work at the moment.

Thanks for any ideas on this one.

Digby

Comments

dig1’s picture

Has anyone else encountered this problem or am I missing something?

I don't mean to create a problem I am just saying what I have found...

Cheers

Digby

Anonymous’s picture

Well I for one think there is something to it, but I can't quite put my finger on what either.

My scenario is a little different but still to do with Menus + Books + Pathauto.

I'm putting it here just in case it is related - I am not trying to hi-jack the thread!

I upgraded from Drupal 6.12 to 6.13.

Whilst using the site after the upgrade to 6.13 I found that the Book navigation and structures were gone. They were also not listing in the menus. New content (Page 'x') being created did not assume an automatic path alias either [default is menupath-raw ] upon saving the node or doing a bulk update via the Pathauto admin area.

The dev version of Pathauto was tried as this was our gut feeling of where it was going wrong (because books may have been breaking as they couldn't 'read' the Pathauto alias for the nodes and also because a new alias could not be created on adding new content), but this did not solve our problem.

We reverted to 6.12 and initially I thought all was working okay, but it wasn't. So the dev version of Pathauto was re-installed and this is when I saw an alias be assigned to a node (Page 'x') with the short path of sitename+nodetitle (ie no menu path inbetween). This had vanished by morning!

Editing the same node and re-saving did not prompt a Pathauto alias.

It was only upon assigning a newly created page (with the same data as Page 'x' - a cut and paste to be exact) to where it was supposed to be in the menu that an alias generated.

That has not stopped this "Whacky Wednesday" though, as now the new Page 'x' has disappeared from the menu drop-down where it was assigned just moments ago, although upon editing the page it still shows as being assigned there.

So then I tried to add Page 'x' to a book (the top level menu TAB where Page 'x' was and disappeared from, is really a blank page and the top level of the book of its own name) and it now appears back in the menu albeit that it did not have its parent check box ticked to be expanded anyway.

I don't know if this makes any sense and I am going to post this now before anything else happens to report.

Needless to say I will be following your issue to see if it helps with mine. Still can't understand why everything was going swimmingly until we tried to upgrade from 6.12 to 6.13 and have thoroughly reverted the core and modules (to the best of my knowledge).

I hope you get your issue sorted out.

[Just noting that the Pathauto that is currently on our system is 6.x-1.1]

dig1’s picture

Well, actually this problem is not really due to changes between 6.12-6.13 but don't worry about highjacking the thread because at the moment you are the only virtual voice in the wilderness...:0

I figure that my best bet is to sit down with a developer at a suitable time and just chew this over because nobody has seemed to latch on to this 'feature' so far...

Cheers

Digby

markhalliwell’s picture

Hello :) I am not sure if this will help or not but I had run into a similar problem as you. It seemed that no matter what token I put in the field it would output to the base URL http://www.example.com/XXXX despite whatever hierarchy I had it in :(

After nearly 3 weeks of debugging the database, PathAuto, Node Hierarchy, and Token I finally figured out that the guilty party is PathAuto!

I'm still fairly new to the whole drupal thing but after some good ol' fashioned trial and error debugging I determined that the fault lies in the pathauto_create_alias() function on Line 293 of pathauto.inc (I'm using: pathauto 6.x-2.x-dev 2009-May-21)

Like I said, I'm still kind of a noob and definitely played around with a few of the modules. At one point during my setup I had played around with the Locale and other language related modules before deciding to nix it until I wanted to devote another summer to implement it lol That being said, I wasn't aware that PathAuto saves a token variable for each language in the database.

PathAuto stores it's token variables in the "variable" table with the prefix of "pathauto_".

As you can see from the code below, if you have any two letter language codes in the variable name (pathauto_node_page_xx_pattern) it will trump every thing else. In my case, it was "pathauto_node_page_xx_pattern" and I am guessing that you will need to change it according to your book module.

Well I deleted all the ones that had the separate language variable, but it still wasn't working. Found out that when you call pathauto_create_alias() with no language variable it looks for "pathauto_node_page__pattern"... which I had in my database :) I'm guessing that it never occurred to them to take out those entries if they were no longer applicable hehe

All this being said, I know I've babbled way too much and I'm sure there is more they can do to fix this issue, but here is a really simple and quick fix to bypass it even if it's in the database! Simply see if the Locale module is enabled :)

I do hope this helps your problem, because god knows I've most certainly been pulling my hair out lol If not, maybe someone else can benefit from this! And at the very least it can be put in a new Dev!

Take Care!

Line: 283

function pathauto_create_alias($module, $op, $placeholders, $src, $entity_id, $type = NULL, $language = '') {

  /* CODE */

  // Retrieve and apply the pattern for this content type
  if (!empty($type)) {
    $pattern = trim(variable_get('pathauto_'. $module .'_'. $type .'_'. $language .'_pattern', ''));            /* Line 293 */
    if (empty($pattern)) {
      $pattern = trim(variable_get('pathauto_'. $module .'_'. $type .'_pattern', ''));
    }
  }
  if (empty($pattern)) {
    $pattern = trim(variable_get('pathauto_'. $module .'_pattern', ''));
  }
  // No pattern? Do nothing (otherwise we may blow away existing aliases...)
  if (empty($pattern)) {
    return '';
  }

  /* CODE */

}

Replace Line 293 with:


    if (module_exists('locale')) {
      $pattern = trim(variable_get('pathauto_'. $module .'_'. $type .'_'. $language .'_pattern', ''));            /* Line 294 */
    }

dig1’s picture

Awesome, let me check this out further. I'll report back events/progress.

Cheers

Digby

dig1’s picture

Status: Active » Closed (fixed)

OK I have just installed a new Drupal setup and the good news is that this problem HAS GONE AWAY...:) Woo Hoo!

So below I have listed my new configuration and in [] afterwards I have listed the old version I was using. I have emboldened the modules that I **think** create and fix the problem. This is for reference and I shall be closing the ticket.

At times like this I just say 'Drupal is a beautiful thing'. Thanks everyone who contributes.

*****************************************************************************************
Drupal 6.13 [6.12]
Views Bulk Operations (VBO) 6.x-1.7
Administration menu 6.x-3.0-alpha3
Advanced help 6.x-1.2
Content Construction Kit (CCK) 6.x-2.5 [CCK 6.x-2.3]
Content Profile 6.x-1.0-beta4
Global Redirect 6.x-1.x-dev (2009-Jun-12) [Global Redirect 6.x-1.2]
Path Redirect 6.x-1.0-beta4 [Path Redirect 6.x-1.0-beta3]
Pathauto 6.x-2.x-dev (2009-Aug-14) [Pathauto 6.x-2.x-dev (2009-May-22)]
Token 6.x-1.x-dev (2009-Aug-13) [Token 6.x-1.12]

Url alter 6.x-1.0
Viewfield 6.x-1.x-dev (2009-Jun-17)
Views 6.x-2.6 [Views 6.x-3.x-dev (2009-Jun-05)]