<?php $this->layout('layouts::_base') ?>

<div class="content" editable=true>
	<?= $content ?>
</div>

<?php
use Parvula\Core\Model\Page;

$i = 0;
$limit = 10;
if (isset($page->options, $page->options['limit'])) {
	$limit = $page->options['limit'];
}

// Order children by date
$children = $page->getChildren();
usort($children, function (Page $p1, Page $p2) {
	return $p1->getDateTime() < $p2->getDateTime();
});
?>

<div class="posts">
<?php if ($children): ?>
	<?php foreach ($children as $child): ?>
		<h3><a href="<?= $baseUrl . $child->slug ?>"><?= $child->title ?></a></h3>
		<p class="post-date font-italic text-muted"><?= $this->e($child, 'pageDateFormat') ?></p>
		<?php if (++$i >= $limit) { break; } ?>
	<?php endforeach; ?>
<?php else: ?>
	<em>Nothing for the moment...</em>
<?php endif; ?>
</div>

<?php $this->layout('layouts::_base') ?>

<div class="content" editable=true>
	<?= $content ?>
</div>

<?php
use Parvula\Core\Model\Page;

$i = 0;
$limit = 10;
if (isset($page->options, $page->options['limit'])) {
	$limit = $page->options['limit'];
}

$children = $page->getChildren();
?>

<div class="posts">
<?php if ($children): ?>
	<?php
	// Order children by date
	usort($children, function (Page $p1, Page $p2) {
		return $p1->getDateTime() < $p2->getDateTime();
	});
	?>
	<?php foreach ($children as $child): ?>
		<h3><a href="<?= $baseUrl . $child->slug ?>"><?= $child->title ?></a></h3>
		<p class="post-date font-italic text-muted"><?= $this->e($child, 'pageDateFormat') ?></p>
		<?php if (++$i >= $limit) { break; } ?>
	<?php endforeach; ?>
<?php else: ?>
	<em>Nothing for the moment...</em>
<?php endif; ?>
</div>

Fix bug if no children
Fix bug if no children
