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
  1. Extending ZauberCMS
  2. BlockListEditor

Content Block

To make it easier to display the Block List Editor editor in the front end, we have a helper view component

@await Component.InvokeAsync("RenderBlocks", new { blocks = Model.ContentBlocks, cssSeparatorClasses = "py-3" })

Where Model.ContentBlocks is just a list of Content from the Block List Editor

public List<Content> ContentBlocks { get; set; } = content.GetValue<List<Content>>("Content") ?? [];

The RenderBlock looks for components that implement the

public interface IContentBlockView : IContentBlock
{
    RenderMode RenderMode { get; }
}

This allows you to render your component in the front end by matching the element type alias. All you have to do is create a Blazor component and implement IContentBlockView like so.

@implements ZauberCMS.Core.Content.Interfaces.IContentBlockView
@if (Content != null)
{
    <div class="fs-6">
        @((MarkupString)(Content.GetValue<string>("Content") ?? string.Empty))
    </div>
}

@code {
    [Parameter] public Content? Content { get; set; }
    public string ContentTypeAlias => "RTEBlock";
    public RenderMode RenderMode => RenderMode.Static;
}

The above is an example of pulling data from the Rich Text Editor and displaying it to the user. The important part is making sure I set the ElementTypeAlias to match the content type being used on this content.

RenderMode

Because these blocks are Blazor and being rendered in .Net MVC, we can specify how we want them to be rendered. Most of the time you will want them to be static, but you can make them InteractiveServer if you have some interactive functionality in them. Just remember to add the Blazor .js script in your layout or any interactivity will not work.

PreviousContent Block PreviewNextCustom List Data

Last updated 3 months ago

Querying Data