# Excerpt issue upgrading from k2 to k3

**URL:** <https://forum.getkirby.com/t/excerpt-issue-upgrading-from-k2-to-k3/20188>\
**Category:** Questions\
**Tags:** v3\
**Created:** [November 28, 2020, 4:14pm UTC](https://forum.getkirby.com/t/excerpt-issue-upgrading-from-k2-to-k3/20188 "2020-11-28T16:14:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikphanson](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/erikphanson/32/1377_2.png) [@erikphanson](https://forum.getkirby.com/u/erikphanson)\
**Post date:** [November 28, 2020, 4:14pm UTC](https://forum.getkirby.com/t/excerpt-issue-upgrading-from-k2-to-k3/20188/1 "2020-11-28T16:14:50Z")

</div>

I’m upgrading from Kirby 2 to Kirby 3 and am getting hung up on an issue with excerpts.

What I had in k2:  
First set up $heroPost to grab the last blog written

`<?php $heroPost = $pages->findBy('uid', 'blog')->children()->listed()->flip()->first() ?>`

Then I had this for an excerpt:  
`<?php echo excerpt($heroPost->text(), 200) ?>`

When I tried to convert that to Kirby 3 excerpt, [$field-\>excerpt() | Kirby CMS](https://getkirby.com/docs/reference/templates/field-methods/excerpt)

`<?php $heroPost->excerpt(int $chars = 200, bool $strip = true, string $rep = ' …') ?>`

I get an error in debug: syntax error, unexpected ‘$chars’ (T\_VARIABLE), expecting ‘,’ or ‘)’

Obviously I’m missing something simple here, any help is appreciated.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 28, 2020, 4:30pm UTC](https://forum.getkirby.com/t/excerpt-issue-upgrading-from-k2-to-k3/20188/2 "2020-11-28T16:30:41Z")

</div>

There are three issues here:

1. `$heroPost` is (hopefully) a page object, not a field object (but `excerpt` is a field method)
2. You don’t call a method with its signature, but with values for the parameters
3. Your code line is missing an echo statement

Correct:

```auto
<?= $page->text()->excerpt(); ?>

```

This will use the method with its default values. If you want to change any of the parameters, e.g. the excerpt length, i.e. without the type hint and the name of the parameter:

```auto
<?= $page->text()->excerpt(300); ?>
<?= $page->text()->excerpt(300, false); ?>
<?= $page->text()->excerpt(300, false, '…'); ?>

```

---

<div class="post-metadata">

**Author:** ![erikphanson](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/erikphanson/32/1377_2.png) [@erikphanson](https://forum.getkirby.com/u/erikphanson)\
**Post date:** [November 28, 2020, 4:41pm UTC](https://forum.getkirby.com/t/excerpt-issue-upgrading-from-k2-to-k3/20188/3 "2020-11-28T16:41:53Z")

</div>

Thanks! That makes sense now. All fixed. I appreciate the help.
