Line break in Text area

Good. Any errors?

No, there is no error

Does the text show up correctly on your web page?

No, it doesn’t. Here a screenshot
image

Here is the yml part:

  Accordionbeschreibungeins:
    label: Produktinfos
    type: structure
    fields:
      Hoehe:
        label: Höhe
        type: text
      Breite:
        label: Breite
        type: text
      Laenge:
        label: LĂ€nge
        type: text
      Bettbreite:
        label: Bettbreite
        type: text
      Bettkantenhoehe:
        label: Bettkantenhöhe
        type: text

and this the corresponding code for the template: <div><?php echo $betten->accordionbeschreibungeins(); ?></div>

In other words, you did not go back to the situation you had when first opening this thread, because that is a structure field. You don’t want a structure field and you did not have a structure field when opening this thread. You had a textarea field.

Try again, you can do it.

Thank you for your encouraging words. This is how I had it when I opened the thread:

  Accordionbeschreibungeins:
    label: Produktinfos
    type: text

Almost. That is a text field. You had a textarea field.

1 Like

Very true, yes, sorry.

So you corrected that, I guess.
Please screenshot the blueprint code, the template code, and the panel interface



Good. Please adjust the contents of the text area to what you would like to have there in the end.
I presume that might be:

Höhe: 90 cm
Breite: 90-200 cm
LĂ€nge: 200 oder 220 cm
Bettbreite: 110-220 cm
Bettkantenhöhe: Standard 38 cm oder Komfort 45 cm
1 Like

This is the result:
image

Perfect. Now that you actually have a textarea field, please click on the link texnixe gave you above and report back here with the first example code you’ll find there under the “How to use in templates/snippets” title.

Try to explain the various parts of that to me.

1 Like

That did it:

<details>
                                <summary>
                                    <button class="accordion-button collapsed bold-accordion-header" type="button">
                                        Produktinfos
                                    </button>
                                </summary>
                                <div><?php echo nl2br($betten->accordionbeschreibungeins()); ?></div>
                                <?= $page->text()->kirbytext() ?>
                            </details>

Yes, but unfortunately it’s wrong.

I see you have copied <?= $page->text()->kirbytext() ?> from the example to your code.
But it seems you don’t completely grasp the concepts behind Kirby or PHP (what is a page, what is a field, what is a field method). I’d like to see where the hiccup is
 So, lets take it apart, piece by piece:

What do the following parts represent to you?

<?=
$page
->
text()
kirbytext()
?>

Also, what do you think that line of code does, or should do, in its entirety?

1 Like

Yes, my knowledge of PHP is that of a beginner, and I’m very grateful for your guidance.

<?= is a php echo command and is designed to output content from the panel on the frondend. This I understand very well.

I’m studying object oriented programming in PHP which uses classes as some sort of design or blueprint for organizing the code and making it easier to retrieve the properties and methods defined in a class. It’s not easy but I’m slowly getting there.

$page is a class name which must contain properties (variables) and methods (functions) that can be utilized by creating an object (instantiating the class).

-> is an object operator designed to access a property or a method. In our case, it’s accessing the text() function and the kirbytext() function which is designed to take care of the formatting for the text field as far as I can see.

If I analyze what I just wrote, it should look like this: <div><?php echo nl2br($betten->accordionbeschreibungeins()->kirbytext()); ?></div>

Sorry! I mean this: <div><?php echo nl2br($betten->accordionbeschreibungeins()->text()->kirbytext()) ?></div>

But this wrong code:

                            <details>
                                <summary>
                                    <button class="accordion-button collapsed bold-accordion-header" type="button">
                                        Produktinfos
                                    </button>
                                </summary>
                                <div><?php echo nl2br($betten->accordionbeschreibungeins()); ?></div>
                                <?= $page->text()->kirbytext() ?>
                            </details>

adds less spacing between the lines (which is desirable).
image

Whereas this code: <div><?php echo nl2br($betten->accordionbeschreibungeins()->text()->kirbytext()); ?></div>

adds too much spacing between the lines
image