Content

Example of of result of the Content Component

The ContentComponent is a flexible way to let users fill in your website's content directly on your website. For this, we use the EditorJS library. Feel free to explore the code and append your own methods and decorations.

To display a content component in your Blade view, use the following syntax:

@include('view.blocks.index', ['model' => $contentRow->content('content')])

Methods:

Default

default(string $default) Sets a default value for the content block.

$contentRow->content('content')->default('Welcome to my site');

Label

label(string $label) Defines a label for the content block.

$contentRow->content('content')->label('Content');

Min

min(int $min) Specifies the minimum number of characters allowed.

$contentRow->content('content')->min(5);

Max

max(int $max) Specifies the maximum number of characters allowed.

$contentRow->content('content')->max(50);

Placeholder

placeholder(string $placeholder) Sets a placeholder for the content block.

$contentRow->content('content')->placeholder('Enter your content here');

Help

help(string $help) Adds helper text below the content block for additional guidance.

$contentRow->content('content')->help('The content will appear on the main page.');

Examples:

@include('view.blocks.index', ['model' => $contentRow->content('content')->label('Content')->help('Keep it short and sweet.')])

Because (for now) content does not have an image block, you can use the following code to display an image and the content block:

<picture class="relative w-full rounded-lg">{!! $contentRow->image('image')->widthPx(800)->getPicture() !!}</picture>
@include('view.blocks.index', ['model' => $contentRow->content('content')])

When you want the user to be able to upload multiple images, with each image having a content block, you can use the following code:

@foreach($blog->list('content_block')->columns(['image', 'content'])->sortable()->get() as $contentRow)
    <picture class="w-full sm:w-220">{!! $contentRow->image('image')->widthPx(800)->getPicture() !!}</picture>
    @include('view.blocks.index', ['model' => $contentRow->content('content')])
@endforeach

Modify or create content blocks

Do you want to change a content block? You can find the Blade file in /view/blocks/*. It is possible to add your own blocks or use existing ones from the EditorJS Awesome Page. To do this, you can make the changes in the /admin/components/content/input.blade.php file. Tip: You can use the blocks and tools provided by the Editor.js community.

No more than once a month
Newsletter