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.1.0.tar.gz (22.9 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.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wagtailmenupage-1.1.0.tar.gz
  • Upload date:
  • Size: 22.9 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.0.tar.gz
Algorithm Hash digest
SHA256 a3e280d1059f90a2e2039c960d6d82d732bc310f42ff71e1cb966f6e5277ef76
MD5 28e0031184641e9914f094f944a64da1
BLAKE2b-256 db0143dbe311fe8ebdfeef64fcaaadceb69d2de13f1fa91e5c6f61340f094d7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wagtailmenupage-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7360169d7076a5319dd302eb68c84260e52eb6b60bc95bc551a432da1ccf63b
MD5 ad9e95625e586067586974ba837bdcc1
BLAKE2b-256 75a2c07c369bae04979f7a25e24ba437e293db033f6faba2e6a08a4d077372f0

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