Skip to main content

Wagtail Nav Menus is a app to provide highly customizable menus in wagtail by leveraging StreamFields.

Project description

Wagtail Nav Menus is a app to provide highly customizable menus in wagtail by leveraging StreamFields.

Why

Remember when websites had tree structures with logical menus that followed the same structure? For many those days are gone. We are asked to create arbitrary menu items, place value props in menus that aren’t even links, and build highly interactive menus with Javascript.

Wagtail Nav Menus addresses this by using stream fields to support arbitrary items in the menu and gives you options to render the menus as both django templates or json for your js tooling to consume.

demo.png

Built in Components

  • Nav Category - a grouping of other components - for things like sub navigation

  • Page Link - Link to a wagtail Page

  • External Link - Django URLField link

  • Django Link - Reverse django view lookups

  • Relative URL - Regex enforced relative links

  • Image

  • Html

Install

  1. Install wagtail-nav-menus with pip.

  2. Add wagtail_nav_menus to INSTALLED_APPS.

Settings

You can add other streamfields like this:

from wagtail_nav_menus.defaults import WAGTAIL_NAV_MENU_TYPES_DEFAULT

WAGTAIL_NAV_MENU_TYPES = WAGTAIL_NAV_MENU_TYPES_DEFAULT + [
    ('page_link_with_image', 'nav_menus_ext.models', 'InternalPageImageBlock'),
    ('page_link_with_image', 'nav_menus_ext.models', 'NavAdvertBlock'),
]

The schema here is (‘name’, ‘module_path’, ‘class name’)

Edit menu name choices. The default is top and footer. These represent different menus for your webpage. The names are arbitrary - but you will look them up by name in templates.

WAGTAIL_NAV_MENU_CHOICES_DEFAULT = (
    ("top", "Top"),
    ("footer", "Footer"),
)

Usage

Nav Menus should appear in wagtail’s settings sidebar tab. CMS uses can control them here.

You may use some template tags to use these in your site.

get_nav_menu

Use this to insert the menu using django templates:

{% load nav_menu_tags %}
{% get_nav_menu 'footer' %}

See the [templates folder](wagtail_nav_menus/templates/) in this repo for examples of rendering the menu. You will want to copy these into your project’s template folder to extend them.

get_nav_menu_json

Use this to get the menu as a json object.

{% load nav_menu_tags %}
{% get_nav_menu_json 'top' as top %}
<div data-menu='{{ top }}'></div>

API Usage

If using Django Rest Framework to access the menu data, this module provides some tools to get started.

Add NavMenuViewSet to your Rest Framework Router.

from wagtail_nav_menus.viewsets import NavMenuViewSet

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_nav_menus-3.14.0.tar.gz (162.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtail_nav_menus-3.14.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file wagtail_nav_menus-3.14.0.tar.gz.

File metadata

  • Download URL: wagtail_nav_menus-3.14.0.tar.gz
  • Upload date:
  • Size: 162.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for wagtail_nav_menus-3.14.0.tar.gz
Algorithm Hash digest
SHA256 bd6754b3f46852beae3f4680b37dc4ae9f545beeeeaa594a0756d31a548af9b2
MD5 9d501b2e884c458fdb63c56b0dfff6a6
BLAKE2b-256 07b7ab66c3c4a65ebd6f848714c6a80ac5b9f53d6cc3215ff72c32da19baab29

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_nav_menus-3.14.0.tar.gz:

Publisher: .gitlab-ci.yml on thelabnyc/wagtail-nav-menus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wagtail_nav_menus-3.14.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_nav_menus-3.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b8f7b2f16886bd567e0668eedf42a0cb5930e171b89e79e463aa1e884d9870d
MD5 8f60b4e9ba524e40325d95b076db56d7
BLAKE2b-256 6b84c073d7a49540ffa018566fce3cf705f5c29f771bc5fcab124c4ec4e8f196

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_nav_menus-3.14.0-py3-none-any.whl:

Publisher: .gitlab-ci.yml on thelabnyc/wagtail-nav-menus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page