Please correct me if I have missed something but as far as I can see the category_pathauto module has not worked with the pathauto module for quite sometime. I believe this is to do with changes in both the pathauto and token APIs.

stenjo outlines the problem as I have also encountered here.

To reflect the changes to the pathauto and token APIs here is a suggestion for the category_pathauto.module code;

NB Please note that the token [categorypathfirst] has been changeed to [categoryfirstpath], this is so that the pathauto module understands the replacement string for this token as "URL safe", thus preventing it from stripping forward slashes.

function category_pathauto_token_values($type, $object = NULL, $options = array()) {

  if ($type == 'node') {

    $node = $object;

    $values = array();

		if (category_is_cat_or_cont($node->nid)) {
			if (!empty($node->cnid)) {
				$cont = category_get_container($node->cnid);
				$values['container'] = pathauto_cleanstring($cont->title);
			}
			else {
				$values['container'] = '';
			}

			$path = _category_pathauto_get_path($node);
			$values['categorypath'] = implode('/', $path);
		}
		else {
			$values['container'] = '';
			$values['categorypath'] = '';
		}

		if (!empty($node->category)) {
			$cid = reset($node->category);
			if (!is_numeric($cid)) {
				$cid = $cid->cid;
			}
			$cat = category_get_category($cid);
			$parents = category_get_parents($cat->cid, 'cid', TRUE);
			$cat->parent = reset($parents);
			$cat->parent = isset($cat->parent->cid) ? $cat->parent->cid : 0;
			$cont = category_get_container($cat->cnid);

			$values['containerfirst'] = pathauto_cleanstring($cont->title);
			$values['categoryfirst'] = pathauto_cleanstring($cat->title);

			$path = _category_pathauto_get_path($cat, $node->title);
			$values['categoryfirstpath'] = implode('/', $path);
		}

	}
		return $values;
}

function category_pathauto_token_list($type = 'all') {
  if ($type == 'node' || $type == 'all') {

		$tokens = array();

		$tokens['node']['container'] =	t('For category nodes, the container of the category.');
		$tokens['node']['categorypath'] = t('For category or container nodes, as [title], but including its supercategories.');
		$tokens['node']['containerfirst'] = t('The container that the page\'s first assigned category belongs to.');
		$tokens['node']['categoryfirst'] = t('The page\'s first assigned category.');
		$tokens['node']['categoryfirstpath'] = t('As categoryfirst, but including its supercategories.');

		return $tokens;
  }
}

Comments

tombh’s picture

Version: 5.x-1.1 » 5.x-1.x-dev
Status: Needs review » Closed (duplicate)

Okay, I see this is already included in the development version, changed status to duplicate.