Unable to load block into composer

Hello.
Could someone please explain to me step by step what I need to do to solve the problem with “Unable to load block into composer. You must edit this content from within the context of the page”.

If relevant, my code for default.php as well as draft_post.php looks the same - as a test.

<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<!DOCTYPE html>
<html lang="<?php echo Localization::activeLanguage() ?>">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <?php
    View::element('header_required', [
        'pageTitle' => isset($pageTitle) ? $pageTitle : '',
        'pageDescription' => isset($pageDescription) ? $pageDescription : '',
        'pageMetaKeywords' => isset($pageMetaKeywords) ? $pageMetaKeywords : ''
    ]);
    ?>
</head>

<body>
    <div class="<?php echo $c->getPageWrapperClass()?>"></div>

    <?php View::element('footer_required'); ?>
</body>

</html>

Now when I go to my page (index.php) and click the cogwheel icon then in Composer - Page I have the above message. But when I click on the right side of the tab icon and select Page then I no longer have this message. Going further when I click on the two card icon and select my Draft Post then I see this message again. I don’t know how to fix it or what is causing it.

Thank you very much for your help and any advice

The problem may lie with the block not the page. Does the block have a composer.php in it’s directory?

I didn’t actually do anything except create a “my_motif” directory in the location:
concrete-cms-9/application/themes/my_motif
and add:
default.php, description.txt, draft_post.php and thumbnail.png to it

I edited my body some more

<body>
    <div class="<?php echo $c->getPageWrapperClass()?>"></div>

    <?php
    $a = new Area('Main');
    $a->display($c);
    ?>

    <?php View::element('footer_required'); ?>
</body>

I noticed that when I go to my_motif and select New Page → Page then after although in Composer it shows me correctly Content → Body
But if I want to add a block again (Dashboard → Pages & Themes → Page Types → Compose Form), I will have the above communique.

So I suspect there is a problem with linking this field to my theme just not sure how to do it…

I think the error is caused by a specific BLOCK that’s being loaded. The error message says “Unable to load block into composer”. Not all blocks can be ‘summoned’ into Composer. Have you tried adding a different block other than the one you actually need?

Are there any errors in Dashboard->Reports->Logs ? Anything in your php error log on your server?

From what I’ve noticed the problem is with assigning a block to an area. Because when I make for my template default.php in my template code

    <?php
        $a = new Area('Main1');
        $a->display($c);
        ?>

    <?php
        $a = new Area('Main');
        $a->display($c);
        ?>

    <?php
        $a = new GlobalArea('Main');
        $a->display($c);
        ?>

You may notice that the area where Composer inserts my data content will be gray and labeled Empty Content Block. However, the same behavior no longer occurs after adding other block elements or using draft_post.php. In addition, you can notice that by changing or adding a letter to Main this block stops working properly. Likewise, changing new Area to new GlobalArea.

So I suspect that I need to point / assign somehow the right block to the right area.

The server is not returning errors to me or CMS.

Maybe the video illustrates more of what I mean

There are some blocks that MUST have a page ID or $c or page object (pick your metaphor) before they can work at all. Their content is necessarily attached to a real page and during the Composer phase, the system doesn’t have that Page info yet. I believe that’s why it’s saying the block needs to be edited on a real page rather than in the pre-page state, if that makes any sense. What you’re experiencing is similar to what happens in my version 9 site(s). I have a page with a Content block and an Image block set up in “Edit Form” and this is what I see when I try to add the page through Composer.
The thing you’re seeing at :26 when you try to add a page is what’s set up in the default page template. You have a Content Block set up in there. The other areas aren’t editable because there’s nothing in them yet. If you click ‘Add Content’ (the + on the toolbar) then you should be able to drag blocks into those empty areas.

None of this is conceptually easy to understand. I NEVER use Composer because it’s too abstract for any of my clients to use. Unless you’re using this every day, you will lose the ‘mental model’ of how it all works. It’s a feature looking for an need IMO.

It turns out that the solution to my problem is quite trivial, I have to go to the :

Dashboard → Pages & Themes → Page Types → Output / Defaults and Output

select there again my page scheme. i will be taken to the block wizard or something like that. there i give a squat with a plus and select / find Composer Control in the list. I drag it to the desired location and in the properties set the block to which it should refer (content, img, etc)

I don’t understand why this is so hidden still additionally behind the website template… but anyway thank you very much for your help and sorry for the confusion :wink:

Yeah, like I said, no client of mine has ever figured it out so I don’t use it. Glad you figured it out.

I think one of the reasons why this part is relatively hidden is because it’s not typically used, especially by content creators and other end users. Most theme developers would set up support for composer programmatically.

If you are building a theme or a block, there is some developer-focused documentation along with a section of the Building a Website with Concrete CMS book that walks you through the process.