New page results in [{ xx }] broken code

Not sure how to debug this one. It’s been a while since I created a new page (I mostly create new blog posts) and I get this mumbo jumbo broken code. In fact it’s been so long it may be the result of something I customized when I first installed Kirby 2 years ago.

I’m on Kirby 3.3.2. Any pointers on how to find what’s broken?

paragraph is a leftover from old page builder code, but I think that was still supported in Kirby 3.3.2 (so before we introduced the blocks field). How are you rendering that field in your template?

Let me guess: you’ve forgotten about the default.php template which two years ago you didn’t intend to use, or use only for the error page.

Your default.php more or less looks like this:

<?php snippet('header') ?>
<?= $page->text() ?>
<?php snippet('footer') ?>

You probably meant to use another template when creating the consulting page. The fact that the default page in the panel selector is just called something like “Page”, “Default page” or “Normal page”, while the more appropriate template would have been under something like “About page” tripped you up.

Here’s what I have in default.php:

<?php ?>
<?php snippet('header') ?>
<main>
  <?php snippet('intro') ?>
  <div class="text">
    <?= $page->text()->kt() ?>
  </div>
</main>
<?php snippet('footer') ?>

What template is default.php calling to render this field?

To your point I’m pretty sure I never did anything with default.php. The code is roughly as you stated.

Should I be pulling a different template for this? I’m not given an option in the menu.

Screen Shot 2022-07-07 at 10.22.35 PM

As for the About page (which I set up 2 years ago and works fine) here’s what the panel looks like:

Please post the blueprint you use for the consulting page (what is the name of the content file of this page)?

As far as I’m aware I haven’t created a blueprint specifically for this page. I used the WYSIWYG admin to create a new page called “Consulting”. So whatever that uses by default is where it’s pulling from.

If it helps this is what’s in default.yml:

title: Simple Page
icon: page
preset: page
status:
  draft: true
  unlisted:
    label: Hidden Page
    text: The page is not listed in the main menu
  listed:
    label: Menu Page
    text: The page is listed in the main menu
pages:
  template: default
fields:
  text:
    type: editor

Note that the About and Home pages work fine, but I customized those 2 years ago when I set up Kirby and don’t recall what I did. This is the first time I’m creating a new page from the admin since then.

Here’s the problem:

your default.yml blueprint specifies that the field text is of type editor.
Your default.php template however treats the text field as “kirby text” (see <?= $page->text()->kt() ?>, kt() stands for kirbytext()).

I’m guessing that the consulting page is using the default template (the blueprint and the screenshots you posted would suggest this). You can verify this by checking the name of the content file (there has to be a *.txt file in /content/consulting ). It probably is default.txt, indicating that it should use the default template.

If this is the case, you could make the consulting page work by changing the code of the default template (/site/templates/default.php). To something like this:

<?php snippet('header') ?>
<main>
  <?php snippet('intro') ?>
  <div class="text">
    <?= $page->text()->blocks() ?>
  </div>
</main>
<?php snippet('footer') ?>

(I’ve changed ->kt() to ->blocks())

I don’t know whether other pages are using the default template however, so by changing that code you could mess stuff up for those other pages.
You might want to check that before committing. The default template is used when the .txt file in the content folder is either explicitly called default.txt or if a template with matching name doesn’t exist in site/templates.

1 Like

Boom. That fixed it. THANK YOU!

However I don’t have a consulting folder in /content so now I have to go figure out that and try to remember how I did the other pages when I set up everything a couple years ago…

BTW my site: http://cameronmoll.com
Adding the Consulting page soon.

As long as the page has status “draft”, you will find it in the /content/_drafts folder.

1 Like