Custom menu titles
BWPanda - January 9, 2009 - 00:01
| Project: | Taxonomy Menu |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
I recently added a Taxonomy Menu to my site, but realised that I wanted the name of the menu to be different from the name of the vocabulary. I couldn't see how this would be possible without a patch, so I created one!
It seems to work well, but let me know if there are any problems.
Hope others find this helpful too.
| Attachment | Size |
|---|---|
| taxonomy_menu-custom_title.patch | 1.6 KB |

#1
Updated patch for new version of TM.
It doesn't quite work properly yet - there's a place to enter your custom name, but I couldn't find the proper place to change the menu name with the custom version, so had a guess. It currently removes the default name if a custom name is given, but doesn't add the new name, so the menu ends up blank...
Any assistance would be much appreciated!
#2
I haven't applied this patch yet, but just by looking at it, remove this line of code:
<?php//set custom menu item name (if any)
$variable_name = _taxonomy_menu_build_variable('item_name', $vid);
variable_set($variable_name, $form_state['values']['taxonomy_menu']['options']['item_name']);
?>
It's not needed. Since you added to the use of hook_taxonomy_menu_options, it saves the variable automatically. Anything in the "options" fieldset is saved as a variable.
Move the next part to the function "_taxonomy_menu_item" It's a helper function for hook_taxonomy_menu_insert and update.
<?php//set custom menu item name (if any)
$custom_name = variable_get('taxonomy_menu_item_name_'. $item['vid'], NULL);
if ($item['tid'] == 0 && !empty($custom_name)) {
$item['name'] = $args['taxonomy_menu']['options']['item_name'];
}
?>
If you were going to do this in a separate/custom module you would use hook_taxonomy_menu_options for and hook_taxonomy_menu_insert/update.
Developer Documentation: http://drupal.org/node/380652
#3
I updated the patch with the changes you suggested, but am still having trouble getting it to work...
<?php//set custom menu item name (if any)
$custom_name = variable_get('taxonomy_menu_item_name_'. $item['vid'], FALSE);
if ($item['tid'] == 0 && !empty($custom_name)) {
$item['name'] = $custom_name;
}
?>
I think it's because
$item['tid']is never equal to '0', or at least, I can't figure out how to trigger that code to change the name...#4
tid should equal 0 when adding an menu link for a vocab item. The code should run when you rebuild the menu and you have "item for vocabulary" selected.
I'll install and debug when I get a chance. I do like this package and plan on adding it to V3.
#5
I edited my taxonomy to do this, but even though 'Item for vocabulary' and 'Select to rebuild the menu on submit' were selected, nothing changed. Either the code's not working or it's not being run...
Glad you like it! :)
#6
Any progress on this?
#7
Merging with this issue since it already has working code. #424160: Module for adding a custom path for the vocabulary only inserts garbage chars (%252F) before the vocab name.
please let me know if you think they are not related.
#8
After reading through, feature requests are not related.
#9
Updated Status
#10
Ok, I think I finally got this working...!
#11
If another person tests this with satisfaction then it can go to RTBC and make it into the 2.5 release.
#12
I did a test and it seems to do as advertised without breaking anything else.
#13
Committed: http://drupal.org/cvs?commit=297860
#14
Automatically closed -- issue fixed for 2 weeks with no activity.