Hi guys,
I'm currently working on a new Drupal 8.0.2 site, I seem to have a problem where the main navigation menu's order seems to keep reverting to alphabetical order instead of the specific fixed order I save it to. Usually when the cache is flushed or when I seem to change pages or edit articles.
I want the order...
Home - News - Campaigns - Events - Organisations - Blogs
however no matter what I do including creating the files in that order from Views pages they always seem to revert back to the alphabetical
Home - Blogs - Campaigns - Events - News - Organisations
Is this a bug or a corrupt setting?
All help appreciated thanks in advance
Comments
On your website go to
On your website go to relative url admin/structure/menu/manage/main
That will take you to the "Edit menu Main navigation".
Click on "Show row weights"
The weight value you choose will determine the order the menu item is displayed. Lower values are displayed before higher values for positive values. Negative values are displayed in reverse where a higher negative value is displayed before a lower negative value.
Everytime you click "Save" you'll see the menu displayed with the order of the weight you set.
Thanks for your reply,
Thanks for your reply, however I know how to set the order, no matter if I use row numbers or drag and drop, the order eventually seems to revert back to alphabetical order. Anyone having similar problems? Regards
Eventually means exactly what
Eventually means exactly what:
Immediately?
Within 5 minutes?
After cache is rebuilt?
Seems after a cache rebuilt
Seems after a cache rebuilt mostly, or occasionally when I make changes to structure of articles in Display suite or Views, but I think that's because that automatically rebuilds the cache maybe?
I am having a similar problem
I am having a similar problem where I have a parent menu "primary-links"
with several child submenus. I created a submenu "Top Issues" with a
weight of -50 and have other pre-existing sibling submenus with a weight
heavier(-48, -46, -44, -42). The menu order shows correct in:
/admin/structure/menu/manage/primary-links
But in the site's drop down menu, all of the pre-existing submenus
are displaying above the "Top Issues" submenu that has the lower weight.
I also tried this:
https://www.drupal.org/node/1007746#comment-9862563
But no luck!!!
Any ideas?
My issue seems to be related
My issue seems to be related to Views, when you create a page and a menu item for that page using views, the order for that menu item seems unable to save it's row weight.
I'll raise it as a bug, if I don't get more feedback.
Same problem here.
Same problem here.
Same problem here, does seem to be views related.
I have the same problem.
The only way I can get around it for now is by deleting all the menu items created by views in the view and then manually adding links under the menu to the path created by views.
I cleared the cache and the menu is now staying in the right order.
Found a fix
Instead of setting the row weights in the Menu pages under Structure/Menus/... , if you go to the Views page for the relevant page instead and you click on the menu link in the Page settings, this opens up a new set of settings for that particular Menu entry here you can set the row weight and it stays saved.
Difficult to explain, let me know if anyone needs help.
Still not working
Bug still remains active as by Drupal 8.1 as reported in this issue: https://www.drupal.org/node/2671612
What a pain!!!
I just had to remigrate my D6 to D8 and the menus did not migrate in the
correct order. it seemed like they are following create order and not the
weight you give them. I recreated all of my primary superfish menus(more
than 100). At one time in one of my main menu I miss 1 so I had to add it
afterwards with the correct weight but it display it on the site as the last
menu with that drop down but it was correct in menu administration page.
I just updated to 8.1.1...
...still happens for me, too. Only way to solve this is to delete every link of the menu and then add them back one by one in the intended order. In my case, I've found that the weights are in fact saved properly - they are correct when checking MenuLinkContent->getWeight() after Drupal::menuTree->load(...) and the weights are shown correctly in the Menu UI (Show row weights) so they have to be stored somewhere - but the subsequent $menu_tree->build doesn't really seem to care.
I am having the same problem.
I'm having the same problem. Very frustrating as I keep having to re-organize my main menu yet it keeps randomly undoing what I've done.
Same problem here, Drupal 8.1
Same problem here, Drupal 8.1.2. Menu order (weights) not retained.
John Studdard
COO, Achieve Agency
p. 561.450.5075
e. jstuddard@achieveagency.com
D'oh! Finally got to the bottom of this
I accidentally discovered the solution on this page:
https://www.drupal.org/node/2226481
After loading a menu it seems to be important to apply the "generateIndexAndSort" manipulator like so:
This will make sure the index is really sorted. Otherwise it is simply unsorted (i.e. in creation order). So you only have the impression that the menu is sorted initially. It never was. And then when you create or change sth. in the menu it all falls apart. All too easy to overlook. Sigh. Don't know if this is everbody else's problem but perhaps it will help somebody. I was looking literally ages for this... Should really be documented better IMHO.
Steps request
Thank you rgpublic. I am not a developer. Would you mind please specifying exactly the steps you took with this information in order to make the menu order stay as configured?
Many thanks. Much appreciated.
m
This only applies for developers!
The problem I found out about only applies if you are rendering the menu *programatically yourself*. If you use the built-in drupal functions like blocks etc. to insert the menu into your site and you have this issue of menu items becoming scrambled, then you are very likely encountering a different issue. Sorry that I can't help you here, but perhaps someone else knows more about this...?
No problem. Thanks rgpublic.
No problem. Thanks rgpublic.
Is there away to add that
Is there away to add that function call to the menu code?
Manipulators really matter
I had the same problem. Thank you, it worked like a charm! :)
From some of the comments
From some of the comments here it seems some are NOT using the default drupal menu block, but a 3rd party module, or even some sort of Views plugin to render the menu.
If you have this issue you MUST explain in EXACT detail how to replicate it, ALL the modules you are using and precisely under what circumstances the issue occurs, if you do not do this you are wasting your time commenting here - sorry but if you want a developer to help you must do these things as a bare minimum. Right now I have no idea how to replicate this issue, certainly it does not happen with Drupal 8 core alone (I've been using it for 2.5 years every day and never seen this, ever).
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Hi Jeff,
Hi Jeff,
I am not sure if that reply was to me but if it was, I was referring to the original problem
as stated by 4site where menus are not following the weight rule.
I was wondering if the solution by rgpublic could be added to the menu code to follow
the weight rule in drupal 8.
Most probably is not that easy.
Thanks!!!
I was talking to everyone :)
I was talking to everyone :)
rgpublic is programatically rendering the men, in a custom module etc. It's the right answer if that is your problem. No else has stated HOW they are rendering the menu - this is very important (programatically youself in preprocess, using a custom module from contrib like Superfish etc etc).
I've been using Drupal 8 for a long time and I havent seen this behaviour - there must be some other code running or there is a serious bug in Drupal core that none other of the 1000 or so people who built Drupal core noticed in the last 3+ years (you see how unlikely that is?).
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Hello,
Hello,
I too am using the core Drupal 8 install without any custom menu modules. I did nothing different than I had done in D7. I simply created a main navigation menu in core as always without doing anything unusual or custom, arranged my tabs and they keep getting reordered alphabetcially. I have tried recreating the menu and it keeps happening. To be specific, I am not using any menu modules other than core and the menu keeps ordering the tabs into alphabetical order automatically. It won't allow me to have them any other way other than in alphabetical order.
Thank you.
M
Superfish not following weights
I'm using just plain Drupal core, the standard Drupal main menu and the Superfish library. When I change the order of the menu's by weight the weights are fine, the admin menu listing is fine, but Superfish shows them the way they were originally entered. I'm using the built in main menu, not one I created myself. I have this same behavior on two different Drupal 8 installs.
I'm not the one to fix this,
I'm not the one to fix this, because I don't know what I'm doing, but I took the code above from rgpublic found a spot in the Superfish plugin where it seemed like it might go and it fixed the problem for me.
From my limited ability to follow the code it seems like it might only work on the sub menus which is where I was having a problem, I didn't try it on the top level items. I also have no idea if there are hidden effects.
Here's what I did, in SuperfishBlock.php:
I added this code in the function expandAll:
The whole function looks like this now:
OK, I tried adding the php
OK, I tried adding the php code following Vadu steps and
after making sure that the caches were clear (several tries)
A miracle, my submenu are displaying correctly according to
their weight.
I also, so far have not seen any hidden effects!!!
Great job Vadu
Thanks!!!
Superfish users please see
Superfish users please see this issue in the Superfish issue queue: https://www.drupal.org/node/2627460
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Fixed it for me
Some previous iteration of this behavior manifested with core menus so I didn't think to check back on Superfish, but applying one of the patches from that thread did indeed resolve it for me. Thanks!
Thank you Jeff but I'm not
Thank you Jeff but I'm not using Superfish or any other contributed menu module. Simply core.
M
Thanks,
Thanks,
$manipulators = array(
['callable' => 'menu.default_tree_manipulators:checkAccess'],
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort']
);
$subtree = $menu_tree->transform($subtree, $manipulators);
above code work for me also.