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.

AttachmentSize
taxonomy_menu-custom_title.patch1.6 KB

#1

BWPanda - April 7, 2009 - 05:34
Title:Allow custom menu titles» Custom menu titles
Version:6.x-1.01» 6.x-2.x-dev
Status:needs review» needs work

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!

AttachmentSize
Taxonomy_Menu-356281-1.patch 1.61 KB

#2

indytechcook - April 7, 2009 - 12:59

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

BWPanda - April 20, 2009 - 02:07

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...

AttachmentSize
Taxonomy_Menu-356281-3.patch 979 bytes

#4

indytechcook - April 22, 2009 - 01:19

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

BWPanda - April 23, 2009 - 02:55

The code should run when you rebuild the menu and you have "item for vocabulary" selected.

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

BWPanda - June 22, 2009 - 04:35

Any progress on this?

#7

indytechcook - July 20, 2009 - 11:16
Status:needs work» duplicate

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

indytechcook - August 25, 2009 - 16:20
Status:duplicate» needs review

After reading through, feature requests are not related.

#9

indytechcook - August 29, 2009 - 22:54
Status:needs review» needs work

Updated Status

#10

BWPanda - November 20, 2009 - 01:09
Status:needs work» needs review

Ok, I think I finally got this working...!

AttachmentSize
taxonomy_menu-356281-10.patch 1.13 KB

#11

indytechcook - November 25, 2009 - 01:53

If another person tests this with satisfaction then it can go to RTBC and make it into the 2.5 release.

#12

indytechcook - December 4, 2009 - 13:26
Status:needs review» reviewed & tested by the community

I did a test and it seems to do as advertised without breaking anything else.

#13

indytechcook - December 4, 2009 - 13:49
Status:reviewed & tested by the community» fixed

Committed: http://drupal.org/cvs?commit=297860

#14

System Message - December 18, 2009 - 13:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.