Skip to content

Not possible to order top menu items #3446

@Yonn-Trimoreau

Description

@Yonn-Trimoreau

When I observe page_block_html_topmenu_gethtml_before event, just like Magento\Catalog\ObserverAddCatalogToTopmenuItemsObserver does, and add some items to the top.menu, I can't order the items I add (whether it should be displayed before or after category listing, for example).

I think it should be possible, since the "top menu" must be one of the first and most modified element on any website.

Maybe by adding a special \Magento\Framework\DataObject attribute "order" which will be used inside or before Magento\Theme\Block\Html's _getHtml method, in a way to reorder the \Magento\Framework\Data\Tree\Node before rendering it ?

Or even clearer : adding a $_position property to the Node class, and a non-mandatory variable to the Node class constructor, which could be used in a similar way I expressed before ?

Simple, non-breaking, no performance issue, really useful. Right ?

I can try to make a pull request if you accept this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions