Not sure if i am using this right; but sure it is a bug as behavior is inconsistent.

I have a single container with hierarchical categories within it. In pathauto Category Path settings i have: [catpath-raw] for my container.

For this structure:
Product Categories [cont]
- Electronics
-- TVs

I want path to be /electronics/tvs. No container value to show.

When i first add a category node (cat_transform) i get the NODE pathauto setting for the alias and not the category alias. When i edit this node and resubmit - i now get the correct Category setting path.

I'll do a little debugging tonight and hopefully add a patch - my guess was a weighting thing; but maybe just cat_pa not doing on submit only on update ???

Comments

liquidcms’s picture

changing title.

I think the issue is that cat_transform and cat_pathauto can't properly work together. When the node is first added it is a "node" and not yet a category so it gets assigned url alias based on the setting in the "Node" section - which does not have the token support added by cat_pathauto. When it is edited after that it is seen as a category and is now assigned url alias based on Categories section of pathauto.

Not sure exactly how to fix this but will keep looking.

liquidcms’s picture

Title: cat_pathauto works when node is edited but not when added » category_transform and category_pathauto not compatible.

title change

liquidcms’s picture

i fixed this in a separate tweak module as this:

/**
 * Implementation of hook_token_list()
 */
function mytweaks_token_list($type = 'all') {
  if ($type == 'node' || $type == 'all') {
     $tokens['node']['category-path'] = "Category path not including container";
  }
  return $tokens;
}

and this:

/**
 * Implementation of hook_token_values()
 */
function mytweaks_token_values($type, $node = NULL) {
  $values = array();
  switch ($type) {
    case 'node':
      $cat_placeholders = category_pathauto_get_placeholders($node);
      $values['category-path'] = str_replace($cat_placeholders['[container]'] ."/", "", $cat_placeholders['[categorypath]']);
  }

  return $values;
}

this allows me to then use [category-path] as the token to use for my sub-category cck type under Node setting in pathauto. It works both when i add or edit a node being transformed into a category.

not sure if this should be patched into category_pathauto; but since i am using category_pathauto_get_placeholders() function from that module it is likely not a bad place to put this???

Peter Lindstrom
LiquidCMS - Content Management Solution Experts