kwalx
June 13, 2016, 1:45pm
1
It seems that toStructure() can’t handle multiline data, so what’s the best solution to overcome this issue?
At the moment I have something like this:
<?php foreach($page->overview()->toStructure() as $overview): ?>
<section class="post">
<h3><?php echo $overview->heading() ?></h3>
<?php echo $overview->text()->kirbytext() ?>
</section>
<?php endforeach ?>
And the page looks like this
Overview:
- heading: first header
text: some text, which should be multiline data.
- heading: 2nd header
text: but in some of these I NEED tables...!
Do you have a better idea? What did I miss here?
You can do it like this:
text: >
single paragraph
text: |
multiple paragraphs
bla blablab akdjajf daj jdjf jfjd fjdj jfdj
kwalx
June 13, 2016, 2:02pm
3
Thank you very much, texnixe.
This works great. But I still need tables in some of them. Having the code directly in the .txt doesn’t work like anyplace else.
What is the smartest way for this?
That’s strange. Are you using kirbytext() to output the content?
kwalx
June 13, 2016, 2:18pm
5
Yes. It looks very funny, because then everything gets collapsed into the first <section>.
Have you made sure that your indentation is correct?
-
title: >
bla bla bla
text: |
| 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|
| 1 | 2 | 4 | 6 | 7 |
| 1 | 3 | 4 | 5 | 6 |
| 1 | 3 | 5 | 7 | 8 |
bla bla bla bla blub
kwalx
June 13, 2016, 2:45pm
7
I took a html table…
well well, this topic is solved.
HTML tables should work as well …
BTW.: If you want to use markdown table syntax, the markdown.extra option needs to be enabled in your config.php.
kwalx
June 13, 2016, 2:55pm
9
Your table is working, the HTML table wasn’t.
Bug or some other stuff going on?
I put an HTML table in and it worked, so not sure this is a bug. I’ve put this into a file:
-
title: >
bla bla bla
text: |
<table>
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>4</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>5</td>
<td>7</td>
<td>8</td>
</tr>
</tbody>
</table>
some more text here ...
kwalx
June 13, 2016, 3:15pm
11
Ok, it works. It is just VERY picky with the correct intendation.
Yep, the YAML syntax is very strict about relative indentation.
If you use the structure field , you don’t have to care about that stuff though as Kirby will indent it properly for you.