Jump to content

[SOLVED] Split mainmenu in two parts (left and right)


Recommended Posts

Hello :)

I'm new to PrestaShop (and to PHP aaaand to Smarty! 😅 ), I'm playing around with the Classic theme trying to adapt it in a child theme. I was able to use custom.css and also to override modules partially (with extends) or totally in this child theme.

But I'm having my first difficulties now, I would like to be able to split the mainmenu (header-top) in half, three items menu on the left and three on the right (numbers could change in the future) without impacting mainmenu in mobile. I found the ps_mainmenu module and understood the foreach loop through the nodes.

I reckon best way to achieve the split is to have two <ul> (with a float right on the second one) but I'm not sure. And I can't figure how to override the code to do that.

Hope I gave you enough informations and reaaally hope to find some help here. Thanks in advance.

Cheers

Edited by Minsky_ae
Edit title to add [Solved] (see edit history)
Link to comment
Share on other sites

Well I'm gonna answer myself if anybody needs the info 😉

I manage to override ps_mainmenu.tpl by breaking the loop at the index I wanted:

{foreach from=$nodes item=node name="left"}
  {if $smarty.foreach.left.index == 3}
    {break}
  {/if}

Then redo the same loop but this time starting the code only when the index was reached:

{foreach from=$nodes item=node name="right"}
  {if $smarty.foreach.right.index < 3}
    {continue}
  {/if}

 

With a bit of CSS override as well in custom.css I've got my two parts menu (left and right). Not sure if it's the best way to do it but until then it works as I wanted.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...