Dear community,
the website I work on currently includes a cute little news section with title, date and content, but only the first two are displayed.
YML
title: News
fields:
news:
type: structure
label: News Items
fields:
date:
type: date
label: Date
title:
type: text
label: Title
content:
type: textarea
label: Content
PHP
<div class="news-section">
<?php
$newsPage = page('news');
if ($newsPage && $newsPage->news()->isNotEmpty()) {
$newsItems = $newsPage->news()->toStructure();
?>
<div id="news-items-container">
<p > +++ PUSH NEWS +++ </p>
<br> </br>
<?php foreach ($newsItems as $newsItem): ?>
<div class="news-item">
<div class="news-header">
<span class="news-date"><?= $newsItem->date()->toDate('d M Y') ?></span>
<h3 class="news-title"><?= $newsItem->title() ?></h3>
</div>
<div class="news-content">
<p><?= $newsItem->content()->text()?></p>
</div>
</div>
<?php endforeach; ?>
</div>
<?php
} else {
echo '<p>No news available.</p>';
}
?>
</div>
when debugging with
<?= var_dump($newsItem->content()) ?>
the news page loads
object(Kirby\Content\Content)#253 (3) { [“date”]=> string(10) “2025-01-01” [“title”]=> string(32) “Residency at Clay Club Den Bosch” [“content”]=> array(5) { [0]=> string(40) “To broaden my practice, I am diving into” [1]=> string(40) “the world of clay, and level my practice” [2]=> string(30) “up to new heights. The journey” [3]=> string(39) “continues. Looking forward to tell you,” [4]=> string(10) “more soon.” } }
I’ve tried several different methods to retrieve the content, such as using kt()
, value()
, and others, but the content field remains empty when displayed on the page, even though it contains text in the backend.
It got me stuck for a while now and I would appreciate your help a lot!