$field->excerpt($length = 140, $mode = 'chars')
Creates a short text excerpt
-
return (string)
Example
<?php foreach($page->children()->visible() as $article): ?>
<article>
<h1><?= $article->title()->html() ?></h1>
<p><?= $article->excerpt(300) ?></p>
<p><a href="<?= $article->url() ?>">Read more…</a></p>
</article>
<?php endforeach ?>
Modes
The excerpt method supports to modes of creating an excerpt: The default one is based on a number of characters. The second mode is to create an excerpt based on the number of words:
<?= $page->text()->excerpt(100, 'words'); ?>