1

Is it possible in M2 to change mobile menu item order? enter image description here

I tried looking and couldn't find. I wanna put settings in the back and put menu item in the front using xml. Basically tried this line <move element="store.links" destination="navigation.sections" after="store.settings" /> and it won't work.

1
  • By default settings are not available in menu theme, and you want to change sort order of menu like, 1.Menu 2. Account 3. Settings Jun 2, 2016 at 9:56

2 Answers 2

1

You can do it with css. See http://caniuse.com/#feat=flexbox and https://developer.mozilla.org/en-US/docs/Web/CSS/order

Example how to use flexbox order:

<!DOCTYPE html>
<header>...</header>
<div id='main'>
   <article>Article</article>
   <nav>Nav</nav>
   <aside>Aside</aside>
</div>

css:

#main { display: flex;  text-align:center; }
#main > article { flex:1;        order: 2; }
#main > nav     { width: 200px;  order: 1; }
#main > aside   { width: 200px;  order: 3; }

Result will be

Nav | Article | Aside

2
  • I am searching a way to change order using xml
    – kilis
    Jun 2, 2016 at 8:17
  • This won't change the order for screen readers or search engines. Oct 21, 2016 at 19:11
0

Add the following code right after <?php if ($detailedInfoGroup = $block->getGroupChildNames($group, 'getChildHtml')):?> in the sections template Magento_Theme::html/sections.phtml

$detailedInfoGroup = array_filter($block->getChildNames(), function($childName) use($detailedInfoGroup) {
    return in_array($childName, $detailedInfoGroup);
});

After adding this, you can change the order as you normally would with XML using before="" / after=""

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.