function taxonomy_menu_path_custom in Taxonomy menu 8
Same name and namespace in other branches
- 7.2 taxonomy_menu_custom_paths/taxonomy_menu_custom_paths.module \taxonomy_menu_path_custom()
Callback for hook_taxonomy_menu_path.
5 string references to 'taxonomy_menu_path_custom'
- TaxonomyMenuCustomPathConfigurationTest::testTaxonomyMenuCustomPathBasePathOption in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuCustomPathConfigurationTest.php - Tests if the path is correct without the depth option.
- TaxonomyMenuCustomPathConfigurationTest::testTaxonomyMenuCustomPathDepthOption in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuCustomPathConfigurationTest.php - Tests if the path is correct with both the base path and the depth option.
- TaxonomyMenuCustomPathFunctionalTest::testTaxonomyMenuCustomPathVocabularyInterface in lib/
Drupal/ taxonomy_menu/ Tests/ TaxonomyMenuCustomPathFunctionalTest.php - Saves, edits and deletes a taxonomy vocabulary using the user interface.
- taxonomy_menu_custom_paths_form_taxonomy_vocabulary_form_alter in taxonomy_menu_custom_paths/
taxonomy_menu_custom_paths.module - Implements hook_form_FORM_ID_alter().
- taxonomy_menu_custom_paths_vocabulary_validate in taxonomy_menu_custom_paths/
taxonomy_menu_custom_paths.module - Validation handler for settings of custom path in the taxonomy vocabulary.
File
- taxonomy_menu_custom_paths/
taxonomy_menu_custom_paths.module, line 99 - Enables custom paths to Taxonomy Menu.
Code
function taxonomy_menu_path_custom($term) {
$path = '';
$tids = array();
$base_path = taxonomy_menu_variable_get('custom_path_base', $term
->bundle(), '');
$depth = taxonomy_menu_variable_get('custom_path_depth', $term
->bundle(), '');
// When tid equals 0, we are dealing with a vocabulary item. We want the path
// to be a mulitple term path.
if ($term
->id() == 0) {
$tids = _taxonomy_menu_get_tids($term
->bundle());
}
else {
$tids[] = $term
->id();
$terms = taxonomy_get_tree($term
->bundle(), $term
->id());
foreach ($terms as $term) {
$tids[] = $term->tid;
}
}
// Build the path.
if ($tids) {
$path = $base_path . '/' . implode('+', $tids);
}
else {
$path = $base_path . '/' . $term
->id();
}
return $depth != '' ? $path . '/' . $depth : $path;
}