3

I want to customize the nav-section component, like changing data, adding more links, and customizing its styling on hover, but I cannot find its phtml or markup file in the Magento theme.

To my knowledge, to customize that component, I just need to find the file, copy it, paste it into my theme folder, and then customize it according to my design.

Is there any way to customize that component without creating it from scratch?

Please, any help would be appreciated.

1 Answer 1

1

In Magento 2, let call the nav-sections is a div or a section instead of component, component means UI component.

The template file responsible for the nav-sections is vendor/magento/module-theme/view/frontend/templates/html/sections.phtml.

To find the template file for the nav-sections in Magento codebase, you should find the word nav-sections in the vendor/magento directory. Here, you will see nav-sections CSS class declared in vendor/magento/module-theme/view/frontend/layout/default.xml which belongs to template Magento_Theme::html/sections.phtml.

6
  • Thanks for the clarification. I couldn't find any template file nav-sections in vendor/magento directory. Commented Oct 13, 2022 at 21:12
  • You missed my point. Could you please read my answer again? nav-sections is the class name of the div, so we find this class name in magento codebase (vendor/magento). Finally, you will find the template you are looking for is vendor/magento/module-theme/view/frontend/templates/html/sections.phtml
    – Tu Van
    Commented Oct 14, 2022 at 1:50
  • Ah, I see, but how do I edit the content of nav-sections. So in the luma theme, nav-section has the default data like 'First Category', 'Men', 'Women'. So I want to replace that with my own data. Commented Oct 14, 2022 at 13:45
  • 1
    They are category names, so you can config them in admin (back office): Admin menu > Catalog > Categories > Select a category to edit. So I would recommend you start as a store owner instead of a developer. Starting with documents on Adobe documents experienceleague.adobe.com/docs/commerce-admin/start/… or video guides series for beginners: youtube.com/…
    – Tu Van
    Commented Oct 14, 2022 at 14:27
  • After that, you can continue to customize magento site. If you have any questions about magento either as a store owner or a developer, you can ask here. I'm available for hire, if your company needs to hire a magento developer to customize, please refer me. Thanks.
    – Tu Van
    Commented Oct 14, 2022 at 14:32

Your Answer

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

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