coderedcms icon indicating copy to clipboard operation
coderedcms copied to clipboard

Subclassing BaseBlock gives me an "Advanced setting" in the editor, but the custom_css_class is not available in the template

Open weholt opened this issue 2 years ago • 1 comments

I love the "Advanced settings" fields in the blocks in crx, but when I try to subclass BaseBlock in my own blocks I see the advanced settings fields in the editor, they're saved correctly, but does not appear anywhere on my object instance and is not available in my templates. What am I doing wrong?

from coderedcms.blocks import BaseBlock
from wagtail.core.blocks import BooleanBlock
from wagtail.snippets.blocks import SnippetChooserBlock


class FamousQuoteBlock(BaseBlock):
    """This will insert a famous quote block"""

    quote = SnippetChooserBlock("quotes.Quote", required=False)
    random_quote = BooleanBlock(required=False)

    class Meta:
        icon = "user"
        form_classname = "quote-block struct-block"
        template = "quotes/blocks/quote_block.html"

weholt avatar May 09 '23 17:05 weholt

Within the block, it should be available as self.settings. You can see an example template here that is using self.settings.custom_css_class: https://github.com/coderedcorp/coderedcms/blob/dev/coderedcms/templates/coderedcms/blocks/image_block.html

vsalvino avatar May 15 '23 17:05 vsalvino

Closing this due to inactivity. Feel free to re-open if you are still experiencing the issue or have any new information. Thanks!

vsalvino avatar May 23 '24 16:05 vsalvino