Skip to main content

A Wagtail page model for creating menu pages.

Project description

wagtailmenupage: Add custom menu items and external links with Wagtail's native menu systme.

Installation

Install the package:

# With pip
pip install wagtailmenupage

# Or Poetry
poetry add wagtailmenupage

(Or your prefered package manager)

Run migrations:

# Standard Python
python ./manage.py migrate

# If using Poetry
poetry run python ./manage.py migrate

Add to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "wagtailmenupage",
    ...
]

Usage

Creating a page

You can add a new Page type for menu items:

Demo screenshot 1

The 'Page' itself is very stripped down. It supports only 3 fields:

Demo screenshot 2

Setting up the template

You can then build a menu using Wagail's built-in system, but these page items will show the correct label and URL:

{% load wagtailcore_tags menupage_tags  %}
{% get_site_root as site_root %}

<nav role="navigation" aria-label="Main navigation">
    <ul>
        {% for menu_item in site_root.get_children.live.in_menu.specific %}
            <li>
                <a
                    href="{% pageurl menu_item %}"
                    {% if request.path == menu_item.url %}aria-current="page"{% endif %}
                    {% if menu_item.open_in_new_tab %}target="_blank" rel="noopener noreferrer"{% endif %}
                >{{ menu_item.title }}</a>
            </li>
        {% endfor %}
    </ul>
</nav>

The above example doesn't show multi-level menus, but that can be done in the regular Wagtail way.

Take note of the logic for opening in a new tab, which is specifically required for this package's open in new tab functionality to work.

You can then re-order your menu items like normal.

For more guidance on using Wagtail menus, please refer to their documentation

Notes

These pages are excluded from the site search, don't use previews, and are excluded from sitemaps generated by the wagtail-seo package.

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

wagtailmenupage-1.1.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

wagtailmenupage-1.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file wagtailmenupage-1.1.1.tar.gz.

File metadata

  • Download URL: wagtailmenupage-1.1.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for wagtailmenupage-1.1.1.tar.gz
Algorithm Hash digest
SHA256 bbb5e48b49db64b0afe4ce87c4e89bf511504226693460fe3b223aa279514631
MD5 b3d6d4ab6ed53c5285ae631d0bf1a081
BLAKE2b-256 ed49663e17337cf01b1b3cf7eaf408035618bd9892a69df6bc032c93770c505c

See more details on using hashes here.

File details

Details for the file wagtailmenupage-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtailmenupage-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b97a31e8b277b402f283af418809628a93520016bab2ff0a0681dffa57137dd9
MD5 516555c6bf9d976a91f0aa503ecb1dfa
BLAKE2b-256 2502c8c4d67889d0b84c1eb244807a05fcbf50e9d87629f3def3a6772d8bac2e

See more details on using hashes here.

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