Skip to main content

Overrides of default Wagtail CRX settings, eg. navbars, footers, etc.

Project description

Wagtail CRX (CodeRed) Settings Override

Overrides of default Wagtail CRX settings, eg. navbars, footers, etc.

Quick start

  1. Install the package from PyPi:

    pip install crx-settings-override
    
  2. Add "crx_settings_override" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
       ...,
       "crx_settings_override",
    ]
    
  3. Add "crx_settings_override.context_processors.navbars" and "crx_settings_override.context_processors.footers" to your TEMPLATES settings like this::

    TEMPLATES = [
       {
          ...,
          "OPTIONS": {
                "context_processors": [
                   ...,
                   "crx_settings_override.context_processors.navbars",
                   "crx_settings_override.context_processors.footers"
                ],
                "loaders": [...]
          },
       },
    ]
    
  4. To make translations work for navbars, override navbar template of CodeRed by creating /templates/coderedcms/snippets/navbar.html and change

    {% if settings.coderedcms.LayoutSettings.site_navbar %}
       {% get_navbars as navbars %}
          {% for navbar in navbars %}
          <ul class="navbar-nav {{navbar.custom_css_class}}" {% if navbar.custom_id %}id="{{navbar.custom_id}}" {% endif %}>
             {% for item in navbar.menu_items %}
                {% include_block item with liclass="nav-item" aclass="nav-link" ga_event_category="Navbar" %}
             {% endfor %}
          </ul>
       {% endfor %}
    {% endif %}
    

    so it doesn't use site_navbar and get_navbars method (this is overriden by the context_processor), eg. simply erase those lines like this

    {% for navbar in navbars %}
       <div>
          <ul class="navbar-nav flex-wrap justify-content-around">
             {% for item in navbar.menu_items %}
               {% include_block item with liclass="nav-item fs-5" aclass="nav-link" ga_event_category="Navbar" %}
             {% endfor %}
          </ul>
       </div>
    {% endfor %}
    
  5. Run python manage.py migrate to create the models.

  6. Start the development server and visit the admin to:

    • create localized navbars under Snippets > Translatable Navigation Bars
    • set one of the localized navbar as a site navigation in CRX Settings Overrides.
  7. Navigation switches automatically based on current site localization.

Development

Update semantic version of the package

Run test update without commiting

$ bumpver update --patch(--minor|--major) --dry

Run update and commit the changes to the repo

$ bumpver update --patch(--minor|--major)

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

crx-settings-override-1.0.0b0.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distribution

crx_settings_override-1.0.0b0-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

Supported by

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