recipe
公開されました August 15, 2024

Designing and Displaying Reusable Navigation Menus

learn-recipe-header-text

紹介

Navigation menus for a site are typically tied strictly to a site's page hierarchy and structure. The Navigation Menus feature in Liferay is powerful because it enables you to create navigation menus that are decoupled from a site's page hierarchy. Liferay navigation menus can be driven by pages, content, categories, and more so that you can design the exact navigation experience you want.

This recipe guides you through creating a custom menu and displaying it as a reusable navigation bar within your Liferay site using Navigation Menus and Master Page Templates.

prerequisites

  • Liferay DXP environment

  • A user with permissions to create and manage Navigation Menus and Master Page Templates

  • Two or more site pages created in Liferay DXP

steps

  1. On your Liferay DXP instance, open the Site Menu, expand Site Builder, and click Navigation Menus.

  2. Click New to create a navigation menu.

  3. Enter Main Navigation for Name and click Save.

    This creates a blank menu and redirects you to its edit page.

  4. Click Add to display a list of available types of items you can add to the menu.

  5. Select the Page item type.

  6. Check the pages you want to include in the navigation menu.

  7. Click Select to save your changes to the menu.

  8. メモ

    You can update a menu item's display name by clicking Actions for one of the items and selecting View Info.

  9. Drag and drop the pages into your desired order.

    Now that you've created a navigation menu, you can incorporate it as a page element within any site page or page template. Here, you'll use it in a master page template.

  10. Open the Site Menu, expand Design, and click Page Templates.

  11. In the Masters tab, click New.

  12. Enter Primary Master Page for Name and click Save.

  13. Open the Fragments and Widgets tab in the side panel.

  14. Drag and drop a Container fragment to the top of the template.

  15. メモ

    When designing a page, it’s recommended to always put elements into their own containers. This can help provide more control over styling.

  16. Go to the Browser tab in the side panel, double-click the name of the container, and rename it Header Navigation Bar.

  17. Select the container and configure these settings in the configuration side panel:

    Tab Setting Value
    General Container Display Flex Row
    General Align Items Center
    General Justify Content Center
    General Container Width Fixed Width
    Styles Spacing > Padding Spacer 3 (top and bottom)
    Spacer 6 (left and right)
  18. メモ

    Use the green boxes to add padding. This adds space between the container and its contents.

  19. From the Fragments and Widgets tab, drag and drop a Menu Display fragment into the Header Navigation Bar container.

  20. 警告

    Make sure you select the Menu Display fragment, not the widget option.

  21. Select the Menu Display fragment.

  22. In the configuration side panel, click Change Source for the menu's source.

  23. Click Main Navigation and click Select This Level.

  24. Click Publish Master.

conclusion

Congratulations! You've learned how to create a custom menu and use it as a navigation bar in your page templates.

ヒント

ヒント

recipe
15 分

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy