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

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

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>
        <li>
            <a
                href="{% pageurl site_root %}"
                {% if request.path == site_root.url %}aria-current="page"{% endif %}
            >Home</a>
        </li>
        {% for menuitem in site_root.get_children.live.in_menu.specific %}
        
            <li>
                <a
                    href="{% pageurl menuitem %}"
                    {% if request.path == menuitem.url %}aria-current="page"{% endif %}
                    {% if menuitem.open_in_new_tab %}target="_blank" rel="noopener noreferrer"{% endif %}
                >{{ menuitem.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.0.1.tar.gz (22.6 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.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wagtailmenupage-1.0.1.tar.gz
Algorithm Hash digest
SHA256 85c39bfeb22f075f28ad6e7c2591e03b9412137fb9965de350ddea6f02712c1f
MD5 3c207677a8c63144bf688c5ea80a2b63
BLAKE2b-256 291f4516e580bc904b40d6d2a419576620e059c0815a4175aeb9ec08d04cd460

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wagtailmenupage-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4feb4aee9038cdf39c973c211a34f4466328a61a4d1a0798e292fa89c65c984
MD5 dc6130b36d37f05f9af48c4bd857ed0d
BLAKE2b-256 f3f7e1dd89d9717831c1316b34711786d43911208acc7049054eb58133e514f5

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