All Projects → squareweave → wagtailcolumnblocks

squareweave / wagtailcolumnblocks

Licence: other
Streamfield columns for Wagtail

Programming Languages

python
139335 projects - #7 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to wagtailcolumnblocks

wagtail-headless-preview
Previews for headless Wagtail setups
Stars: ✭ 99 (+160.53%)
Mutual labels:  wagtail, wagtail-cms
wagtailmath
Beautiful equations in your StreamField content
Stars: ✭ 27 (-28.95%)
Mutual labels:  wagtail, wagtail-cms
WF-website
Website for Western Friend, part of the Religious Society of Friends
Stars: ✭ 34 (-10.53%)
Mutual labels:  wagtail, wagtail-cms
gatsby-source-wagtail
Plugin for sourcing Gatsby data from Wagtail CMS
Stars: ✭ 16 (-57.89%)
Mutual labels:  wagtail, wagtail-cms
wagtailclearstream
A work-in-progress app to make Wagtail's StreamField more modular
Stars: ✭ 33 (-13.16%)
Mutual labels:  wagtail, streamfield
wagtailvideos
Videos for Wagtail CMS, including transcoding
Stars: ✭ 43 (+13.16%)
Mutual labels:  wagtail, wagtail-cms
react-streamfield
Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
Stars: ✭ 34 (-10.53%)
Mutual labels:  wagtail, streamfield
wagtail-react-streamfield
Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
Stars: ✭ 75 (+97.37%)
Mutual labels:  wagtail, streamfield
wagtailgridder
Wagtail Gridder is a Bootstrap 4 enabled layout for the Wagtail CMS. Grid Items are created within categories, and displayed on a Grid Index Page. The JavaScript libraries Gridder and MixItUp are included.
Stars: ✭ 59 (+55.26%)
Mutual labels:  wagtail, wagtail-cms
wagtaildraftail
🐦📝🍸 Draft.js editor for Wagtail, built upon Draftail and draftjs_exporter
Stars: ✭ 23 (-39.47%)
Mutual labels:  wagtail
wagtail-redirect-importer
Note: This library is now included in Wagtail 2.10, use the builtin version instead of this.
Stars: ✭ 15 (-60.53%)
Mutual labels:  wagtail
vagrant-wagtail-develop
A script to painlessly set up a Vagrant environment for development of Wagtail
Stars: ✭ 36 (-5.26%)
Mutual labels:  wagtail
wagtail-simple-gallery
A simple gallery app for Wagtail. https://pypi.org/project/wagtail-simple-gallery/
Stars: ✭ 41 (+7.89%)
Mutual labels:  wagtail
digihel
City of Helsinki Digital Helsinki Wagtail CMS
Stars: ✭ 19 (-50%)
Mutual labels:  wagtail
wagtail-cache
A simple page cache for Wagtail based on the Django cache middleware.
Stars: ✭ 63 (+65.79%)
Mutual labels:  wagtail
wagtail-import-export
UNMAINTAINED. Try wagtail-transfer, the evolution of this package: https://github.com/wagtail/wagtail-transfer/
Stars: ✭ 31 (-18.42%)
Mutual labels:  wagtail
wagtailenforcer
The Wagtail arm of the law - enforce security protocols on your Wagtail site
Stars: ✭ 43 (+13.16%)
Mutual labels:  wagtail
wagtailmodelchoosers
A Wagtail app to pick generic models (rather than snippets or pages)
Stars: ✭ 23 (-39.47%)
Mutual labels:  wagtail
localore
Wagtail-based CMS and Ansible playbooks for Localore: Finding America
Stars: ✭ 16 (-57.89%)
Mutual labels:  wagtail
wagtail-filepreviews
Extend Wagtail's Documents with image previews and metadata from FilePreviews
Stars: ✭ 21 (-44.74%)
Mutual labels:  wagtail

A generic, reusable column block for Wagtail's StreamField.

Allows developers to create column layouts with a number of different layout ratios that are supported in the admin in a visually appealing way.

Admin interface showing column blocks in a streamfield

A basic frontend template is included, but no frontend CSS. Due to the variations of responsive layouts and frontend layout frameworks, frontend templates should be overridden by the developer.

Installation

Once you have set up Wagtail, you should just need to do the following:

  1. pip install wagtailcolumnblocks
  2. Edit INSTALLED_APPS in your settings.py to include 'wagtailcolumnblocks'.

Usage Example

Assuming you have set up Wagtail according to these instructions (and those above), you can see wagtailcolumnblocks in action as follows.

Edit home/models.py to look like this. HomePage is from the original templated code, and we've added SidebarPage and the *Blocks classes:

from django.db import models

from wagtail.core.models import Page
from wagtail.core import blocks
from wagtail.core import fields
from wagtail.embeds.blocks import EmbedBlock
from wagtail.images.blocks import ImageChooserBlock
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel

from wagtailcolumnblocks.blocks import ColumnsBlock


class MyContentBlocks(blocks.StreamBlock):
    """
    The blocks you want to allow within each MyColumnBlocks column.
    """

    image = ImageChooserBlock()
    text = blocks.CharBlock()


class MyColumnBlocks(blocks.StreamBlock):
    """
    All the root level blocks you can use
    """
    column_2_1 = ColumnsBlock(
        # Blocks you want to allow within each column
        MyContentBlocks,
        # Two columns in admin, first twice as wide as the second
        ratios=(2, 1),
        # Used for grouping related fields in the streamfield field picker
        group="Columns",
        # 12 column frontend grid (this is the default, so can be omitted)
        grid_width=12,
        # Override the frontend template
        template='home/blocks/two_column_block.html',
    )


class SidebarPage(Page):
    content = fields.StreamField(MyColumnBlocks)

    content_panels = [
        FieldPanel('title'),
        StreamFieldPanel('content')
    ]

class HomePage(Page):
    pass

Edit home/templates/home/sidebar_page.html to look like this:

{% extends "base.html" %}
{% load static %}
{% load wagtailcore_tags %}

{% block content %}
<div class="row">
    {{page.content}}
</div>
{% endblock content %}

Edit home/templates/home/blocks/two_column_block.html to look like this:

{% load wagtailcore_tags %}

<div class="row">
    {% for column, width in columns %}
        <div class="col-xs-12 col-md-6">
            Column width = {{ width }}
            {% include_block column %}
        </div>
    {% endfor %}
</div>

Run python manage.py makemigrations && python manage.py migrate to add our SidebarPage migration and execute it.

In the Wagtail admin you should now be able to create a Sidebar page which shows up in a two column layout. When you view or preview the page you should see the templated content.

Deployment

Deployment to pypi should happen automatically via travis-ci.org once the commit on master is tagged appropriately.

License

Licensed under the BSD 3-clause "New" or "Revised" License.

(c) 2019, Squareweave. All rights reserved.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].