ZauberCMS
  • 🪄Welcome to ZauberCMS
  • Getting Started
    • 💡Quick Start
      • Databases
  • Creating A Website
    • 📹Website Build Video Tutorial
    • Content Types
      • Element Types
      • Compositions
    • Current Content Properties
      • Textbox & Textarea
      • Text Editor (Radzen)
      • Text Editor (TinyMCE)
      • Numeric
      • True / False
      • Rating
      • Checkbox, Dropdown & Radio Lists
      • Media Picker
      • Navigation
      • Material Icon Picker
      • Content Picker
      • Date Picker
      • Custom Component Picker
      • Api Key Picker
      • Colour Picker
      • Block List Editor
      • Editor Notes
      • Google Map Location Picker
      • Simple List Manager
      • Simple Dictionary Manager
      • SEO Property
      • Code Editor
      • Colour Theme Picker
    • Content
      • Publish & Unpublish
    • Querying Data
      • Extension Methods
    • Views
    • Controllers (Route Hi-Jacking)
    • Custom Components
    • Users & Roles
      • Restrict Access By Role
    • Logs
    • Audit
    • Global Settings
      • Using Global Settings
    • SEO Sitemaps
    • Hosting
  • Extending ZauberCMS
    • Overview
    • BlockListEditor
      • Content Block Preview
      • Content Block
    • Custom List Data
    • Custom Content Property
    • Custom Validation
    • Custom Admin Sections
      • Section Nav Group Menu
      • Trees
        • Tree Context Menus
      • Reusing Content Editors
    • Saving Custom Data
    • Using AppState Events
    • Before & After Save
    • Email & Storage Providers
    • Seed Data
    • SEO Checks
  • Identity
    • Overview
    • External Authentication Providers
    • Account Layout
  • Language
    • Overview
    • Adding Language Dictionaries
    • Setting The Language
    • Using Language Dictionaries
  • AppSettings
    • Detailed Errors
    • Media Settings
    • Enable Path Urls
Powered by GitBook
On this page
  • Content Blocks
  • Content Block Previews
  • Custom Styling
  1. Creating A Website
  2. Current Content Properties

Block List Editor

Value Type Saved: List<Content>

PreviousColour PickerNextEditor Notes

Last updated 5 months ago

The Block List Editor allows you to pick Element Types and update the content directly in the editor, save and sort the content. It then displays the content item in a list of blocks.

The blocks are customisable and you can display custom content in them using the IContentBlockPreview. In addition, for rendering on the front end, you can create a view to match the block using the IContentBlock

Example of getting value on page

var blocks = Content!.GetValue<List<Content>>("Content");

Then you can use the built in component to render the blocks

@foreach (var block in blocks)
{
    <div class="py-3">
        <RenderBlock Content="@(block)" TView="IContentBlockView"/>
    </div>
}

Content Blocks

To display data in the front end, you create a Blazor component and implement IContentBlock. Example below is a QuoteBlock.razor from my blog.

@implements ZauberCMS.Core.Content.Interfaces.IContentBlockView
<div class="prose md:prose-lg">
    @if (Content != null)
    {
        <figure class="text-end">
            <blockquote class="blockquote">
                <p>@(Content.GetValue<string>("Quote"))</p>
            </blockquote>
            <figcaption class="blockquote-footer">
                @(Content.GetValue<string>("Cite"))
            </figcaption>
        </figure>
    }
</div>

@code{
    [Parameter] public Content? Content { get; set; }
    public string ContentTypeAlias => "QuoteBlock";
}

Content Block Previews

To customise what you see in the admin section, you can override the default view and render a component. A lot of the time you will just want to render the Content Block, and because this is Blazor you can easily reuse blocks. The example below, is for the quote block again, where I just render the original QuoteBlock.razor in my QuoteBlockPreview.razor.

@implements ZauberCMS.Core.Content.Interfaces.IContentBlockPreview

@if (Content != null)
{
    <QuoteBlock Content="@Content" />
}

@code {
    public string ContentTypeAlias => "QuoteBlock";
    [Parameter] public Content? Content { get; set; }
    [Parameter] public ContentType? ContentType { get; set; }
}

Custom Styling

You can style the block list editor in the admin to match your website by linking your front end style sheet in the Block List Editor Settings. Just click on the settings icon on your Block List Editor and add the CSS file path. Must be relative to your website root, like you would add in your code.

Once this is done, ZauberCMS uses the shadow DOM to append the style sheet so your custom styles, only affect the blocks and not the rest of the admin. You can make the editing experience pretty nice! Below is my blog, I have set up the components and the styles.

Your ContentTypeAlias is the Element Type alias and you just use the Content property like you do in the normal .

ContentViews
BlockListEditor
Block List Editor Settings
Example showing the Block List Editor and the front end content and styling