diff -urp 5.x-2.11/faq.module 5.x-2.x-dev/faq.module --- 5.x-2.11/faq.module 2008-06-12 21:44:15.000000000 +1000 +++ 5.x-2.x-dev/faq.module 2008-06-20 10:48:54.000000000 +1000 @@ -797,6 +797,10 @@ function faq_weight_settings_form_submit * questions and answers. */ function faq_page($tid = 0) { + if (module_exists('pathauto')) { + _pathauto_include(); + } + // Things to provide translations for. $default_values = array(t('Frequently Asked Questions'), t('Back to Top'), t('Q:'), t('A:')); @@ -812,6 +816,13 @@ function faq_page($tid = 0) { $breadcrumb = array(); if (!empty($tid)) { + if (!drupal_lookup_path('alias', arg(0) .'/' .arg(1)) && module_exists('pathauto')) { + $placeholders = pathauto_get_placeholders('taxonomy', taxonomy_get_term($tid)); + if ($alias = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) .'/'. arg(1), arg(1))) { + drupal_goto($alias); + } + } + $current = taxonomy_get_term($tid); $breadcrumb[] = array('path' => 'faq/'. $tid, 'title' => $current->name); while ($parents = taxonomy_get_parents($current->tid)) { @@ -1281,15 +1292,22 @@ function _get_indented_faq_terms($vid, $ $term_node_count = db_fetch_object($result); if ($term_node_count->c > 0) { + $path = "faq/$term->tid"; + + if (!drupal_lookup_path('alias', arg(0) .'/'. $term->tid) && module_exists('pathauto')) { + $placeholders = pathauto_get_placeholders('taxonomy', $term); + $path = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) .'/'. $term->tid, $term->tid); + } + if ($faq_count) { $node_count = $term_node_count->c; if ($hide_child_terms) { $node_count = $tree_count; } - $cur_item = $term_image . l($term->name, "faq/$term->tid") ." ($node_count) ". $desc; + $cur_item = $term_image . l($term->name, $path) ." ($node_count) ". $desc; } else { - $cur_item = $term_image . l($term->name, "faq/$term->tid") . $desc; + $cur_item = $term_image . l($term->name, $path) . $desc; } } else { @@ -1814,3 +1832,33 @@ function theme_faq_answer_category_heade return $answer_header; } + +/** + * Implementation of hook_pathauto(). + */ +function faq_pathauto($op) { + switch ($op) { + case 'settings': + $settings = array(); + $settings['module'] = 'faq'; + $settings['token_type'] = 'taxonomy'; + $settings['groupheader'] = t('FAQ category path settings'); + $settings['patterndescr'] = t('Default path pattern (applies to all FAQ categories with blank patterns below)'); + $settings['patterndefault'] = t('faq/[vocab-raw]/[catpath-raw]'); + $settings['bulkname'] = t('Bulk generate aliases for nodes that are not aliased'); + $settings['bulkdescr'] = t('Generate aliases for all existing nodes which do not already have aliases.'); + + $patterns = token_get_list('taxonomy'); + foreach ($patterns as $type => $pattern_set) { + if ($type != 'global') { + foreach ($pattern_set as $pattern => $description) { + $settings['placeholders']['['. $pattern .']'] = $description; + } + } + } + $settings['supportsfeeds'] = 'feed'; + return (object) $settings; + default: + break; + } +} \ No newline at end of file