New Editor acting up 🤷‍♂️

Hi there,

I’m setting up my first Kirby site. Loving it until now. (and love the fact that I can use Blade templating ;-))

I have a problem with the new editor though. Probably something simple but can’t seem to get my head around it.

I’m using pages as sections that you can fill up with the new editor but when i echo $page->text()->blocks() or $page->text()->blocks()->html() I get nothing. Although if I var_dump them I do get something back.

I’ll elaborate a bit on my setup. (btw, it’s not the blade engine, I also tried everything with just simple php tags & echo’s)

Blueprint

    title: Hero
    preset: page
    pages: false
    changeTemplate: false
    fields:
      text:
        label: Text
        type: editor

Listing the sections (Had to remove the @'s from blade because the form thought I was mentioning people)

    section('content')
        foreach($page->children()->listed() as $section)
            include($section->template())
        endforeach
    endsection

Example of an paragraph with the blocks

    <p class="paragraph">
    {!!var_dump($section->text()->blocks())!!}
    {!!$section->text()->blocks()->html()!!}
    </p>

Output of the var dump
2020-05-01_01-26-21 (6)

Content of the field

    [
        {
            "attrs": [],
            "content": "Test",
            "id": "_jm5tx7197",
            "type": "paragraph"
        }
    ]

If I var_dump the ->html() I get nothing.

Any ideas? :sweat_smile:

Does it work if you do without using Blade in your templates? Im gussing Blade is interfering somehow.

Oh… just noticed you tried that. Hrm. Is everthing up to date? What server are you using? What php are you using? When you say you tried it without Blade, did you just not use blade in the templates, or completly remove the blade plugin? i would think the code still goes through the blade plugin even if you dont use it in the templates because it will still be looking for blade tags to process.

Also, could you post the full PHP only code you tried?

Which Blade plugin are you using, there are three of them?

This one (https://github.com/beebmx/kirby-blade). I think I saw it somewhere on the Kirby site or twitter.

Hmm, if I remove the blade plugin I indeed ge more repsonse from the block function. :confused:
@texnixe Which blade plugin do you guys recommend?

I’ve never used Blade, so I can’t recommend anything. You might want to create an issue in the repo, it has recently seen updates, maybe something was messed up.

Yeah, might stop using it, It adds a extra layer of things that can go wrong… I tried the other blade plugin and that gives an " Fatal error : Cannot redeclare e()…" because of the Illuminate\Support functions.

(Tip for you guys, maybe you can add a if(!function_exists(‘e’)) arround the e() helper in kirby/config/helpers.php ;-))

Thx for the help though @texnixe and @jimbobrjames

No, we cannot simply do that, because Kirby relies on these functions to work in a defined way.

Same problem with this plugin. Opened an issue: Fatal error when installing the plugin with latest version of Kirby · Issue #4 · beebmx/kirby-db · GitHub
Anyways, in the plugin code, they protected the function like this:

if (! function_exists('e')) {
.........

This looks like a load precedence problem of the function. Plugin function loaded first.

Response from here: Fatal error when installing the plugin with latest version of Kirby · Issue #4 · beebmx/kirby-db · GitHub

Since Kirby 3.7 all the helpers should be deactivated.

Here’s the explanation for deactivate globally every helper.

In short, you need to add this line of code (one or another):

const KIRBY_HELPER_E = false;

define('KIRBY_HELPER_E', false);