Everytime I submit content to some category the top menu item of that particular category gets is displaced. Usually the menu item gets thrown at the bottom of the list but it also varies.

I am creating the primary menu from 4 vocabularies here's an example from my vocabularies.

Articlevocab:
-Item1
--item
--item
--item

Videovocab:
-item2
--item
--item
--item

Blogvocab:
-item3
--item
--item
--item

Primary menu before: Item1 | Item 2 | Item 3
Primary menu after submitting content to Item1: Item 2 | Item 3 | Item 1

I hope this bug gets fixed asap. since it renders the module at the end user point of view damn near useless.

At first I tought this would be only major bug but after I wrote the last sentence decided to bump this to critical. If you think otherwise feel free to lower the priority.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jthomasbailey’s picture

I've been having this problem with 6.x, still haven't figured it out.

olrandir’s picture

I'm having a very similar issue my self, posting here in case it's relevant.

I'm using taxonomy menu to create a menu of categories (taxonomy terms) for a site. The issue I encountered is, when adding content (e.g. creating a new article) and applying a category to it (via a term reference field connected to the appropriate vocabulary), the link to the corresponding taxonomy term is duplicated in the menu! E.g. if the node is added to the taxonomy term "shopping", the menu gets appended with a top-level link to "shopping", even if this already exists.

This started happening after I added a new taxonomy term and rebuilt the taxonomy menu. Rebuilding the menu now has no effect.

filijonka’s picture

hi

question: is the taxonomy vocab tree correct after submission?

/Peter

olrandir’s picture

In my case at least, the vocabulary is unaffected. The extra items only get added to the taxonomy menu.

jthomasbailey’s picture

I think I figured out what's causing it for me, are you using Content Taxonomy?

jviitamaki’s picture

Nope, I have only Taxonomy Menu and Taxonomy modules.

cybernostra’s picture

Same case on D7 and D6, submited content with a taxonomy term used as menu term exclude the menu item from the menu tree and replace it as "parent". I have to act within the mesu tree list to arrange the term again inside the hierachical menu.

jthomasbailey’s picture

Hmm. With mine (D6) it was only breaking the menu if I used Content Taxonomy, core Taxonomy didn't affect it. Anyway I unchecked "Add item for vocabulary" in the taxonomy menu settings and it seems to have fixed the problem (fingers crossed).

Chris Pergantis’s picture

We are using Taxonomy and Taxonomy Menu with Ubercart in Drupal 6 to provide a contextual menu for a client's catalog. I hope this anecdote will help to locate the issue(s).

From the following context "admin/content/taxonomy/1" I can add terms with no probelms but after they are added I am not able to make any structural changes. We are using a hierarchy structure with mulitple parents for a given term. The structure takes changes within the terms at the taxonomy side. When I press update after making a change to the hierarchy it then regenerates the menu and trashes the menu structure. The taxonomy structure remains intact with no problems.

If i make any changes on the menu side of it (i.e. changing the qualities of "admin/build/menu-customize/primary-links") the menu gets trashed in a very similar manner. Intuitively it looks as though a change in a weight for an item either on the taxonomy side or a menu item having its weight or its enabled or expanded status changed would cause the same havoc.

I will be more than happy to give more information if someone needs it. Just ask.

parisek’s picture

Subscribe

mpotter’s picture

I am also having this problem with the 7.x-1.x-dev version. However I have learned that the problem only occurs if I also have additional custom menu items in the same menu. For example, I have a Taxonomy called "Page" that determines what "page" an article is shown on and the "page" taxonomy is used to create the main tab menu along the top of the site. If I manually add a webform item called "Contact Us" and add it to the main menu then this triggers the problem.

Once the Contact item is added to the menu, editing any article causes the Page taxonomy term menu item to get moved to the end of the menu (after Contact).

This all worked correctly on D6 with the D6 version of Taxonomy Menu, so something changed in the 7.x version.

UPDATED: Found a workaround. The step that causes the problem is reordering the menu with the custom Contact item to drag Contact to the end of the menu. This causes the weights of all menu items to be reset to negative values. So instead of dragging the Contact item with the GUI, turn on the Show Weights option in the Menu item list and change the Contact item to have a weight of 50, leaving the taxonomy menu items alone. Then the menu does not get re-ordered when content is edited.

So this might be more of a core issue with how menu item weights are assigned when using the drag/drop interface.

elgandoz’s picture

Hi can confirm the same wrong behaviour in 7.x-1.1. The above workaround works perfectly don't works, but i have some site with many levels and about 80 terms...if there were more then 100 terms it will be impossible make the menu works correctly (i leave client submit products by himself). By the way order is reseted only inside the current level, so the category three is respected.
Additionaly in one site I'm using "Menu attributes" for give to each menu item a custom id or class, making a colour based navigation.... after submitting custom classes and ids are gone.
Same configuration in D6 worked perfectly.
Hope in a patch or update soon...

OldAccount’s picture

Same issue, using 7.x-1.2. Adding or editing a node (in my case, an Ubercart product) rearranges my menu items. I'm not adding new terms, simply tagging new content with existing terms. The parent items that were tagged are moved to the end of the menu and reset to expanded.

OldAccount’s picture

This is a really critical issue for us, any plans on addressing it soon?

timtunbridge’s picture

+1 please please fix

kevinquillen’s picture

This happens to me when I add/edit/disable views that touch TVI (http://drupal.org/project/tvi) which in turn are also tied to vocabs using Taxonomy Menu. Every single time I enable/disable a view or view display, the taxonomy menu simply vanishes and I have to go back and rebuild it.

OldAccount’s picture

We're a few weeks away from going live with a site using this module and this bug is critical. Is there any other module that provides similar functionality? This one doesn't appear to be maintained any more. :(

dstol’s picture

@lrobeson Thanks so much for your contributions. I'm sorry that YOUR client is paying YOU to use Drupal and taxonomy menu for free. Your critical deadlines aren't my problem as I maintain this module in my free time as a volunteer.

That aside. This is a core issue that exists in 6.x and 7.x.
@see
#550254: Menu links are sometimes not properly re-parented
#566094: menu_tree_data() doesn't build proper hierarchy

OldAccount’s picture

You're absolutely right, and I do appreciate your time working on this module. I sincerely apologize. I'll check out the 2 issues you mentioned, thank you.

Sucheta’s picture

Hello All,

Even I have faced same issue logged in at http://drupal.org/node/1244942.

Kindly guide if there is any solution on this.

Best Regards,
Sucheta Nair.

mropanen’s picture

Happens for me too; after editing the menu (adding, deleting, updating items) the hierarchy is reset to some kind of partly-alphabetic order. Rebuilding the menu through taxonomy vocabulary settings fixes it, but isn't quite convenient.

Using the latest dev (Nov 30)

Chris Pergantis’s picture

Guys, not so sure if this will help what you are having trouble with but one of our developers, 'Ben Coleman', put the following out there - try looking at post 498182 there are a couple of patches there by him. It requires a patch to core from him which is also referenced there.

anrikun’s picture

Subscribing.

obutuz’s picture

+1, can some guru please sort out this issue? Thanks

Milosavlevski’s picture

There are several hooks/functions in taxonomy_menu.module that cause menu reordering on node manipulation. Once I've removed them, the problems were gone.

hook_node_insert()
hook_node_update()
hook_node_presave()
hook_node_delete()
_taxonomy_menu_nodeapi_helper()

They probably only exist to handle on-the-fly addition of taxonomy terms on the node form (tags, hierarchical select...)

constantinejohny’s picture

Hi, I had the same problem on several pages in D7. The solution I found is quite simple. You have to set the Weight for each term in the taxonomy dictionary. By default when you just rearange your terms by dragging them it sets values like -50, -49 ... I set them starting at 0, continuing 1, 2 ... and it works. I can add content without rearanging the menu accidentaly :)

If it doesn't work try do the same in the Menu list. Let me know if it works and if there is a way to make this work properly without setting the weight values manually.

figureone’s picture

Guys, I think we're a little off base on the source of this issue. Here's what I've just found:

1) Taxonomy Menu creates menus from taxonomies; this means it is taking data from the taxonomy_term_data table and putting it in the menu_links table;

2) Both taxonomy_term_data and menu_links have a "weight" field, set to int(11);

3) However, if you look at the Drupal admin interface for editing Taxonomies and Menus
/admin/structure/taxonomy/yourtaxonomy
/admin/structure/menu/manage/yourmenu
you'll notice that the Weight column (make sure you see it by turning on "Show row weights) is different in each. Editing taxonomies presents a select dropdown that goes from -230 to 230, while editing menus presents a select dropdown that goes from -50 to 50.

4) Say I have a taxonomy term with weight 51, and I use Taxonomy Menu to import the vocabulary containing that term into a menu. If I look at the new menu in the database (menu_links), it will have a weight of 51, like it should. But if I then go into the Drupal menu editor (/admin/structure/menu/manage/yourmenu) and look at the assigned weight in the select dropdown, it will say -50. It's doing this because the real value, 51, is out of bounds of -50..50.

5) I've tested this behavior by changing the weight field in menu_links. If I set it to 50, it shows as 50 in the Drupal menu editor. If I set it to 51, it jumps to -50.

6) Ultimately, this looks like an issue based on number constraints that aren't specified in the database fields. Both weight columns are int(11), but it looks like Drupal is restricting menu weights to -50..50, and taxonomy weights to -230..230. When converting between the two, like Taxonomy Menu does, we might need to enforce a mapping. I haven't yet looked into the Drupal core code to see where these bounds are enforced.

edit:
7) I forgot to say how this causes the reordering: Basically, when displaying the menu, Drupal honors the -230..230 bounds used in the table; however, the menu editor maps -230..230 to -50..50 when building the select dropdowns, so if you happen to make changes to the menu and then save them, the weight field in menu_links is overwritten with the values in the select dropdown boxes, which are limited to -50..50.

figureone’s picture

Follow-up to #29, regarding weights:

Drupal menu weights get capped at -50..50 (see /modules/menu/menu.admin.inc:111).
Drupal taxonomy weights, however, expand to match the size of the taxonomy (see the increment on delta in the do-while loop: /modules/taxonomy/taxonomy.admin.inc:286).

So you'll notice that the select dropdowns for weight in the Drupal menu editor (/admin/structure/menu/manage/yourmenu) are capped from -50..50.
But the select dropdowns for weight in the Drupal taxonomy editor (/admin/structure/taxonomy/yourvocabulary) will be slightly larger than the number of items in your taxonomy.

The number 230 that I quoted in post #29 came about because the vocabulary I was testing on had 228 items. Thus delta was calculated as 230, and the select dropdown went from -230 to 230.

In order for this particular error to be fixed, the value for delta in menu.admin.inc should not be hardcoded (it needs to be calculated on the fly like in taxonomy.admin.inc). For the time being, I've changed line 111 in taxonomy.admin.inc from:
'#delta' => 50,
to:
'#delta' => 500,
so it fits my taxonomy menu of 228 items (I could have specified any number above 228, I just want to give it room to grow).

I'll submit a bug report to the menu module in core separately.

figureone’s picture

Patch submitted to core, follow that thread to see the fallout!

dcam’s picture

Status: Needs work » Active

A client asked me to look into this issue yesterday. They've been trying to implement taxonomy_menu across several of their sites and were having the same problem. They were trying to set the link order of menus generated by the module in the menu links admin page. Then whenever a node tagged with one of those taxonomy terms was saved, the weight of that term's link would change. This morning figureone in #29 helped me confirm that the taxonomy weight is overriding the link's weight whenever a node is saved.

When I checked out the code, it seemed that this is how the module is intended to function. I may be taking the comment on line 538 of taxonomy_menu.module out of context, but it says:

'weight' => term weight
(This will be overridden by the order created from taxonomy_get_tree which respects the correct weight)

The taxonomy term's weight is inserted right into the link's weight whenever a node is saved. Unfortunately, it seems like a lot of people, including my client, are expecting the link weights to be editable via the menu admin page and not revert to the taxonomy weights.

Fortunately, hooks are provided to modify the attributes of the term's $item, including the weight, before it's turned into a link. I knocked out a quick module which overrides the default taxonomy term's weight, replacing it with the current weight of the link if it exists.

function mymodule_taxonomy_menu_insert(&$item) {
  $item = _mymodule_taxonomy_menu_item($item);
}

function mymodule_taxonomy_menu_update(&$item) {
  $item = _mymodule_taxonomy_menu_item($item);
}

function _mymodule_taxonomy_menu_item($item) {
  $mlid = _taxonomy_menu_get_mlid($item['tid'], $item['vid']);
  if ($link = menu_link_load($mlid)) {
    $item['weight'] = $link['weight'];
  }
  return $item;
}

This solved the issue here on my test server. We'll see if it sticks tomorrow when they try to implement it on their sites.

anou’s picture

Must say : thanks a lot for the custom module code ! Works like a charm.

dstol’s picture

Status: Active » Needs work

dcam, thanks for the custom module. It would be great it if could be adapted into taxonomy_menu itself.

xjm’s picture

Status: Active » Needs work

If you're encountering this issue, you should also try updating Drupal core to 7.12. See #1007746: Reordering fails with more than 100 items in a menu.

OldAccount’s picture

Upgrading to 7.12 didn't fix this issue for me and unfortunately the patch for #1007746: Reordering fails with more than 100 items in a menu didn't fix it either, adding a new product messes the menu up just like before. Unless I'm missing a step-- should I have "Select to rebuild the menu on submit" checked?

figureone’s picture

@lrobeson, could I get a snapshot of your misbehaving taxonomy and the menu generated from that taxonomy? The raw data straight from the database would be most helpful, but a screenshot of the drap-and-drop editor interface in Drupal (with the weights visible) works too.

From mysql:
SELECT name, weight FROM taxonomy_term_data;
SELECT link_title, weight FROM menu_links;

OldAccount’s picture

Here you go, hope it makes more sense to you than it does to me.

BTW, I set up a Rule to reset the menu on cron runs using this code, not sure if that's part of my problem:

<?php
	db_query("UPDATE menu_links SET expanded='0' WHERE menu_name='menu-primary-nav'");
	db_query("UPDATE menu_links
		SET weight = CASE mlid
		WHEN 1599 THEN '-50'
		WHEN 1638 THEN '-49'
		WHEN 1706 THEN '-48'
		WHEN 1776 THEN '-47'
		WHEN 1770 THEN '-46'
		WHEN 1159 THEN '-45'
		END
		WHERE mlid IN (1599,1638,1706,1776,1770,1159)");
		include_once './includes/bootstrap.inc';
		drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
		drupal_flush_all_caches();
?>
my evil twin’s picture

@#12
Posted by elgandoz

Did you fix this issue?

It's driving me insane. Everytime I edit a node that's in a menu, the class or id settings are removed.

eyal_barouk’s picture

Thanks dcam!
Registered

gumrol’s picture

#28 worked like a charm - easiest solution on the page! Thank you.
In the end I'm not sure which ordering worked - the menu or the taxonomy - I ordered both as you said and voila!
My issue was: I add content and link it to a taxonomy and my taxonomy menu order reshuffled every time, thanks constantinejohny for the solution.

figureone’s picture

@lrobeson, from what I can tell, I'm not positive your issue is caused by Taxonomy Menu. I'm not sure what your Ubercart setup is, but my guess is that's involved somehow. It looks like the weights for most of your taxonomy menu items are set to 0, which could be contributing.

Note that the Taxonomy Menu module under Drupal 7 is different than under Drupal 6. Most notably, options such as synchronizing don't exist in the Drupal 7 version. This means that when items are added to the taxonomy, the corresponding menu only gets updated when you select "Select to rebuild the menu on submit." from the taxonomy editor.

criscom’s picture

I have several Menus on my site. One is called Explore by and is a Taxonomy Menu. When I update or create a page and select some Taxonomy for the menu, the Taxonomy Menu gets rearranged from Explore by to the Main menu. I have to go to aadmin/structure/menu/manage/main-menu and edit the Taxonomy terms to pull them again into the Explore by menu. I am sure this issue is related.

criscom’s picture

Is this an isolated phenomenon? Or should I post it in as a separate issue? Pls advice.

aendra’s picture

If it helps anyone not wanting to patch core to get around this problem or wait for an official solution -- I was using Taxonomy Menu for only one menu, which won't ever really change, so I found just disabling the module altogether to be the best solution. All my menu items are still there -- and now don't randomly change whenever I edit content.

middlenewman’s picture

Thanks for the simple solution aendrew! This also resolved: http://drupal.org/node/1453404 for when not only were items getting rearranged, but the items I had disabled, kept enabling after submitting a page with that tag.

this_is_it’s picture

#32, @dcam. I also checked out this module's source code, btw, there's a question, that's why it matters while saving or updating nodes(implement hook_node_insert, update), I mean, that users create or update nodes has nothing to do with 'taxonomy menu', is it right? or am I missing something?

NenadP’s picture

Here, on D7, all this is happening, menu rearanges on edit taxonomies, disabled taxonomy menu items are being enabled misteryously, custom classes are forgotten... :(

I needed to convert taxonomy menu links to "normal" ones and here is what i did:

I disabled module. Menu links can't be deleted or treated as normal ones as they are bound to taxonomy_menu module in menu_links database table.
In database table menu_links, there is field with name name: module . I renamed the field value for menu items created with Taxonomy menu module, from "taxonomy_menu", to "menu". Now i can edit and delete links like it was created with menu module!.

This of course means goodbye to Taxonomy menu module, but as i needed the module mainly to bulk create menu structure from taxonomies, it was solution for me.

Sql query was UPDATE menu_links SET module='menu' WHERE module='taxonomy_menu'

warning: Dont try this though, if you are not sure what you are doing, and javing database copy for the sake of disaster :D .

dcam’s picture

@this_is_it: Taxonomy menu has implementations of hook_node_insert() and hook_node_update() on lines 368 and 383 of taxonomy_menu.module, respectively. So yes, the module does do something on node creation/updating. Both functions call handlers which update the menu link.

this_is_it’s picture

@dcma: So can we delete these hooks(hook_node_insert, hook_node_update, hook_node_delete) from this module? I can't see affections on menu building.

dcam’s picture

@this_is_it: I suppose you could, if you really wanted to go that route.

It's been a while since I studied the module in-depth, but I seem to recall that those hooks were put in place for a specific circumstance. If a taxonomy term doesn't have any nodes tagged with it, the module won't make it into a menu link. Those hooks enable the link to be automatically created if a node is added or updated with a previously unused term.

If I had a site that used Taxonomy menus, was concerned about having the menus automatically update like that, and wanted to take over management of the menu structure after Taxonomy Menu initially created them, then I would just disable the module as #45 suggested rather than modifying its code.

this_is_it’s picture

@dcam, Thank you for your explanation.

Actually, this module has implemented hook_taxonomy_term_insert, hook_taxonomy_term_update, hook_taxonomy_term_delete, when someone adds/updates/deletes a term to a vocabulary, then it adds/updates/deletes corresponding menu link automatically. it's not necessary to trigger node hook, it doesn't make sense.

You're right, what I want is to auto-generate menu links from taxonomy terms. I don't wanna bother any more, just using #45 solution or commented those node hooks. This module is great, but I think the implementation logic is a little bit more complicated.

johnv’s picture

On my system this does not occur when the Taxonomy menu is assigned to a sub-item of an existing menu.
It does happen when I create a new (empty) menu (hence, as top menu item, and no parent), and assign the Taxonomy menu to that new, empty menu.

Reassigning the Taxonomy between the two menu's makes the problem appear and disappear.

In another issue, a similar problem was resolved by replacing empty($parents) by !isset($parents) ( or vice versa)
#1540472: Taxonomy Menu Apr 19, 2012 dev throws Warning: array_flip() [function.array-flip]

tanitani’s picture

#11 mpotter - thanks seems to help (I had a similar use case).

mike27’s picture

This is not only a matter of reordering. It is a kind of "updating" the menu items.

This means that if you use another module (supplementary) such as Menu attributes, every time that you submit a node, the ids or classes via menu attributes are lost (obviously it ignores these fields).

To sum up, a (very) temporary solution is to disable the Taxonomy Menu, once you set your desired structure (As mentioned in #45).

Be careful: Do not uninstall the Taxonomy Menu module because this will delete all menus created using the module.

If anyone can suggest a patch or a safer solution, it is very much appreciated.

Thanks,
mike

tanitani’s picture

Hi mike,

Did disabling the module solve the problem in the long run for now?

Tx

Gábor

cimo75’s picture

+1

mksweet’s picture

I am confirm this is a bug. Whenever a node is edited, the menu order changes. Disabling the module does seem to work as a stop-gap solution but doesn't seem sustainable in the long run (another developer takes over the site and uninstalls it by accident, etc).

Floris Vedder’s picture

#28 worked for me.
The menu inherits the weight values from the taxonomy vocabulary. Set the weight for each taxonomy term in the taxonomy vocabulary in the order you prefer.(see #30 if you have more than 50 taxonomy terms).

If you have additional menu items that are not taxonomy related like #11 then give them a weight that isn't used for one of the taxonomy terms.

This only is a workaround when you are not using an auto-complete field for your taxonomy term. Cause it seems that every new generated taxonomy term has a weight value of '0'.

hles’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
vivalogue’s picture

Sadly No.28 hasn't worked for me. Weights in both Taxonomy and Menu changed manually, but when add new content, the menu re-orders, even though the weight value hasn't changed.

nikosnikos’s picture

#32 works perfectly in my case with taxonomy_menu 7.1
What it does in fact, is that it doesn't change the weight in the menu if it already exists. And that's what I expected, I change the order of the term only in the menu.

johnv’s picture

dfletcher’s picture

The small customization module solution in #32 worked perfectly for me, thanks dcam.

niki v’s picture

#53 is a solution that works very well.

Create a menu link (any), assign it to the designated taxonomy menu, disable it and set it as the parent of all other links in Taxonomy menu. I tried a number of the suggested fixes and that was the most painless to implement and survived testing and shifting around menu items.

Thanks johnv!

Update: That worked until cron ran and then my entire menu was trashed, so back to square 1

Proteo’s picture

Thanks a lot dcam, #32 fixed the issue for me!

kumkum29’s picture

Hello,

I tested the custom module (#32) but without success. I'm using version 7.x-2.0-alpha2 of taxonomy menu. If I click on "Save" in the list of terms, the weights are reset (0,1,2,3 ...). Then, the weight of the terms are not the same as the weight of the menu items. The order of menu items is not the same as the terms.

Have you managed to synchronize the weight between the terms and menu items with version 2?

Thank you for your reply.

randomyao22’s picture

Issue summary: View changes

In my case, #32 is really helped.

I just found this problem is only happened when I tick the 'Hide empty terms' in Taxonomy menu Options. If I uncheck this option, the problem will go away. This is what #52 are talking about.

So you don't need to disable Taxonomy menu, you can just disable the 'Hide empty terms' option. But you can't hide empty terms then.

elkz’s picture

#32 work great for me, taxonomy menu are not rearranged when I edit a term. Weight is good.
Update of Internationalization (7.x-1.11) do the same thing but apparently only on childs terms… so #32 is still needed.

Now If you installed Menu Attributes, class sets to your taxonomy menu link will be remove every time you update your taxonomy term (adding Metatags, …).

update of #32 :

<?php
function ordertermtaxomenu_taxonomy_menu_insert(&$item) {
  $item = _ordertermtaxomenu_taxonomy_menu_item($item);
}
function ordertermtaxomenu_taxonomy_menu_update(&$item) {
  $item = _ordertermtaxomenu_taxonomy_menu_item($item);

}
function _ordertermtaxomenu_taxonomy_menu_item($item) {
  $mlid = _taxonomy_menu_get_mlid($item['tid'], $item['vid']);
  if ($link = menu_link_load($mlid)) {
    $item['weight'] = $link['weight'];
  }
  return $item;
}

function ordertermtaxomenu_menu_link_alter(&$item, $menu) {
    if (!empty($item['mlid'])) {
        $mlid = $item['mlid'];
        $link = menu_link_load($mlid);
        if (isset($item['options']['attributes']) && is_array($item['options']['attributes']) && !isset($item['options']['attributes']['class'])) {
            $item['options']['attributes'] = $link['options']['attributes'];
        }
    }
}
?>

hope this help

[edit] bug :
class were still not removed but I could not edit them any more or add some more
so the edited code above seems to work fine now :)
[edit] bug :
adding a if (!empty to the hook

redhatusr’s picture

this bug exists also in stable version 7.x-1.5. trying to use this module with Commerce a main menu item is change every time a save a product. every time a save a product with catalog term 'for women' the main menu item 'for woman' change its position from second to last.

redhatusr’s picture

module #69 (#32) has working for me until I add a description to Blog content type

Notice: Undefined index: attributes in ordertermtaxomenu_menu_link_alter() (line 21 of /var/www/commerceK11/sites/all/modules/ordertermtaxomenu/ordertermtaxomenu.module).

Recoverable fatal error: Argument 1 passed to drupal_attributes() must be an array, null given, called in /var/www/commerceK11/includes/theme.inc on line 1646 and defined in drupal_attributes() (line 2377 of /var/www/commerceK11/includes/common.inc).

The content type Blog has been updated.

After this error I cannot return to any page, I can't use the site because menu disappears and all the pages contain this error msg. full disaster!

Any ideas where to look about this?

elkz’s picture

Sorry I'm not using this module (#69) with Commerce.
I installed it on 3 websites since I posted it here and I have not encountered any problems… :/

I'll take a look.

elkz’s picture

OK redhatusr #71, I had the same bug.

I get my site back like this : (copy and) delete the contents of ordertermtaxomenu.module > Flush cache > Set the code again in ordertermtaxomenu.module > Flush cache.

I cheated a bit for clearing cache : I copied the url before. But there are other ways to do : https://www.drupal.org/node/42055

I'll try to fix this bug. :)

EDIT

Try this :

<?php
cache_clear_all();
function ordertermtaxomenu_taxonomy_menu_insert(&$item) {
  $item = _ordertermtaxomenu_taxonomy_menu_item($item);
}
function ordertermtaxomenu_taxonomy_menu_update(&$item) {
  $item = _ordertermtaxomenu_taxonomy_menu_item($item);

}
function _ordertermtaxomenu_taxonomy_menu_item($item) {
  $mlid = _taxonomy_menu_get_mlid($item['tid'], $item['vid']);
  if ($link = menu_link_load($mlid)) {
    $item['weight'] = $link['weight'];
  }
  return $item;
}

function ordertermtaxomenu_menu_link_alter(&$item, $menu) {
    if (!empty($item['mlid'])) {
        $mlid = $item['mlid'];
        $link = menu_link_load($mlid);

        if (isset($item['options']['attributes']) && is_array($item['options']['attributes']) && !isset($item['options']['attributes']['class']) && isset($link['options']['attributes'])) {
            $item['options']['attributes'] = $link['options']['attributes'];
        }
    }
}
?>

The cache_clear_all(); function is only here to resolve #71 error. You have to delete it after the upgrade.
For a basic installation of this custom modulethere is no need of it : delete it.

hope this help :)

ANDiTKO’s picture

#32 Code dosent work on node edit/add. It still re-orders them after adding or editing a node (in my case commerce product).

Disabling the module however fixed the problem.

This patch still needs work.

Another solution is to use views to display your taxonomies and then order them however you want. I want alphabetical order by title. Just create a view block and make sure you cache the whole block so it dosent impact site performance.

ron_s’s picture

Thank you for all the comments and feedback on this thread. We only have about 50 items in our menu, so we shouldn't be faced with any of the 'greater than 100' issues. Whenever the client modifies a taxonomy term description or adds a new node, the menu item weights are re-arranged.

Like @mpotter mentioned in #11, we have a mix of taxonomy term menu items and custom menu links created by the client in the menu. This seems to add to the problem.

As well, we have "Auto expand menu items" enabled in the taxonomy menu settings. This is important because our navigation menu expands on hover to show all sub-items. When a taxonomy term is modified (such as by updating the term's description field), it causes major issues for the menu item expand settings. Something becomes seriously broken in the database, because the "Show as expanded" checkbox will be checked under the Menu Item Settings, but the menu does not show as expanded.

The *only* way to fix when the menu item enters this state is to edit the menu item, unselect the checkbox, save the menu item, and then edit the menu item again, select the "Show as expanded" checkbox, and save the menu item a second time. Only after taking these steps does the menu display as expanded.

I'll have to concur with others that the best approach for now is use Taxonomy Menu to set up your menu as you wish, then disable the module once this is complete.

captcha’s picture

I faced this issue when creating content, on our site the taxonomy menu only has vocabulary terms and no custom links.

Also got a 'website error' at some point when rebuilding menu in which case, the menu would get deleted but not rebuilt. In this case, when i created new content and selected the terms that were deleted while rebuilding the menu, the terms started to show up.

Eventually, I have disabled taxonomy menu for now, after getting the current state of the menu to what we needed but I guess new terms will not be added to the menu automatically while the module is disabled, so this isn't really a solution but a temporary workaround.

I'm using 7.x.1.5 version.

mendelbaum_nm’s picture

One of the tricky solutions is to change
$item['weight'] = $item['root_term_weight']
to
$item['weight'] = $item['root_term_weight'] - 50
This makes the weight for the updated menu item to set as the weight of taxonomy term weight in the vocabulary minus 50.
So you will always have the same order in the menu as in the vocabulary (because menu weights start with -50, vocabulary weights start with 0).
Sure, to make this solution universal it needs to be refined. But at least it made it possible to solve the problem which was making my client mad

EDIT: In case you have some permanent custom links in the beginning of the menu on same level as taxonomy menu links - value of 50 has to be reduced on the amount of this custom links. Yeah, I know... but at least it works.

suntower’s picture

This is a bad one. I am using Commerce Kickstart 2 which -requires- this module. I've hacked it to not update existing menus until fixed.

For -me- the simple answer would be an option that does -not- automatically rebuild the menu upon taxonomy term edit.

mendelbaum_nm’s picture

suntower, turning off the checkbox "Synchronize menu with changes in the vocabulary" in the vocabulary settings should do the trick for you, isn't it?

Chris Pergantis’s picture

Delete

Chris Pergantis’s picture

Delete

nicholasruunu’s picture

I solved it by using this hook: (haven't been tested in production)
If you're using flat menu, change $item['weight'] to $item['root_term_weight']

/**
 * Makes top level taxonomy menu links keep their weight
 *
 * Implements hook_taxonomy_menu_update().
 */
function hook_taxonomy_menu_update(&$item) {
  if ($item['ptid'] !== '0') {
    return;
  }

  $menu_link = menu_link_load($item['mlid']);
  $item['weight'] = $menu_link['weight'];
}
fineartist99’s picture

The issue is using negative numbering for weights. If you use positive numbers nothing gets shifted around.

amaisano’s picture

Custom module in #82 works great. Makes loads of sense, too.

Dr.Osd’s picture

Custom module in #82 works, thanks.

vksgautam’s picture

Menu loss weight while updating another plugins