Content Blocks "Build Template" not working

Hi all,

In Content Blocks, when trying to create a new template, or edit an existing one, the Build Template function is not working [it just sticks at “Loading Data”] and something is causing a 500 error when I attempt to use it:

This was working until recently - not sure what’s changed.

I can’t find any events triggered in the Modx Manager Error log or any local PHP error_log

Any thoughts gratefully appreciated.

PHP 8.1 — MODX 3.0.1-pl — Content Blocks 1.12.1-pl

When you switch to the “Network” tab in the developer console.
What are the request-parameters of the request that fails (especially the “action”) and is there some error message in the response?

Hey @halftrainedharry

Under Payload:

action: mgr/template_builder/getvars

The Preview and Response tabs are empty.

Hey folks - just wondering if any further thoughts on this one?

As ContentBlocks is a paid extra, maybe try to contact modmore directly or use their specific forum.


I don’t have a version of ContentBlocks running on MODX 3 and PHP 8.1, so I can’t say if this is a general problem or something specific to your installation.

Can you check your servers’ error log? It’s certainly not supposed to throw a 500 error on that URL, but it’s a bit hard to see why that would happen without the detailed error. Could be a compatibility issue but also a custom input type that breaks it, for example.

Hi @markh

Thanks - the server php error_log files aren’t registering anything on this event. I agree you’d think that detail on the error must be logged somewhere but I cannot find it.

I don’t have any custom input types but I have created custom Layouts and Fields.

These all work great. It’s just on clicking the “Build Template” button that I get the problem.

Do you know what it’s retrieving exactly on the action: mgr/template_builder/getvars … ?

Thanks for your time - I know you’re busy.

Not sure if it’s at all relevant - but every time I visit the Manager Actions page [not the error log] I get multiples of errors in the Manager Error Log file along these lines:

[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbTemplate from mysql.cbtemplate
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1675) Could not load class cbTemplate!
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbTemplate from mysql.cbtemplate
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 786) cbTemplate::load() is not a valid static method.
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1675) Could not load class cbLayout!
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 786) cbLayout::load() is not a valid static method.
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1675) Could not load class cbLayout!
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 786) cbLayout::load() is not a valid static method.
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1675) Could not load class cbLayout!
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 786) cbLayout::load() is not a valid static method.
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1675) Could not load class cbLayout!
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbLayout from mysql.cblayout
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 786) cbLayout::load() is not a valid static method.
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbCategory from mysql.cbcategory
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1675) Could not load class cbCategory!
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbCategory from mysql.cbcategory
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 786) cbCategory::load() is not a valid static method.
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbField from mysql.cbfield
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 1675) Could not load class cbField!
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 666) Could not load class: cbField from mysql.cbfield
[2022-06-28 18:33:19] (ERROR @ /home/xxyyzz/2022/core/vendor/xpdo/xpdo/src/xPDO/xPDO.php : 786) cbField::load() is not a valid static method.

I think these are only generated when visiting that page.

In addition - the following errors are generated when saving some content-blocks-enabled Resources, but not others:

[2022-06-28 15:52:02] (ERROR @ /home/xxyyzz/2022/core/components/contentblocks/model/contentblocks/contentblocks.class.php : 596) [ContentBlocks] Could not find input 0 for parsing.
[2022-06-28 15:52:37] (ERROR @ /home/xxyyzz/2022/core/components/contentblocks/model/contentblocks/contentblocks.class.php : 596) [ContentBlocks] Could not find input 0 for parsing.
[2022-06-28 15:53:46] (ERROR @ /home/xxyyzz/2022/core/components/contentblocks/model/contentblocks/contentblocks.class.php : 596) [ContentBlocks] Could not find input 0 for parsing.
[2022-06-28 15:53:58] (ERROR @ /home/xxyyzz/2022/core/components/contentblocks/model/contentblocks/contentblocks.class.php : 596) [ContentBlocks] Could not find input 0 for parsing.

Again possibly not relevant.

None of the above errors are generated when trying to “Build Content”.

Hmm I’m not able to replicate the problem. I’m also using PHP 8.1, MODX 3.0.1.

That’s very strange if nothing’s showing up in the PHP logs - it should do for a 500 error. :thinking:
Have you got the server set to log to the one location? I know with some hosts (cPanel for example) they leave log files all through the directory structure depending on where the error occurred.

Also in regards to that “could not find input” error message, it’s most likely that your system setting

contentblocks.default_field

is set to a field id that doesn’t exist any more.

Thanks @digitalpenguin - everything worked fine for me too - until it didn’t! I just don’t know what I’ve done to break it.

Yep - I don’t understand this either. I can search the MODX directory - there are three error_log files:

image

But none of these are getting updated on this 500 error.

I might ask my hosts if they can help track down the detail of the error.

Hmm … it’s set to 0 and always has been but I think that’s the right track.

I’ve worked out that the “could not find input” error occurs when I save a resource which contains the default layout [Full Width] - so a brand new page, with no content, as below, will register that error whenever it’s saved:

Interestingly, if I use Switch Layout to switch it to a different layout, the error still occurs.

And … if I delete the default layout and add a new Full Width layout, the error disappears.

So it’s something to do with the default deployment of the Full Width layout.

I guess it could be related to the main issue.

Many thanks for you time :+1:

I’ve now solved the main issue here.

I have a Content Blocks Layout which contains a setting allowing the user to select a bunch of resources.

It does this by calling a snippet in the Field Options to list available resources.

The snippet code is a modified version of this.

However, it looks like the first line:

$current_ctx = $modx->resource->get('context_key');

was generating an error:

PHP Fatal error:  Uncaught Error: Call to a member function get() on null in /home/xxyyzz/core/cache/includes/elements/modx/revolution/modsnippet/92.include.cache.php:2

This error didn’t appear until I enabled debugging.

I’ve removed the context-related code from the snippet [it’s a single context site] and all seems to be back to normal!

Thanks everyone for your time :+1:

The [ContentBlocks] Could not find input 0 for parsing error remains but I don’t believe it is causing problems at the moment.