Skip to content

read_time with Bard sets throws string conversion error #4343

@mynetx

Description

@mynetx

The read_time modifier cannot traverse into sets within Bard fields.
Instead, an Array to string conversion error is shown.

Statamic 3.2.9 Pro
Laravel 8.62.0
PHP 8.0.9
jonassiewertsen/statamic-documentation 1.5.0
webographen/statamic-dynamic-token 1.0.0
withcandour/aardvark-seo 2.0.16

Discussed in #4341

Originally posted by austriker27 September 30, 2021
Hello!

Has anyone gotten the read_time modifier working with bard when you have sets?

I found this post for awhile ago but its not working for me (post is from V2):
https://statamic.com/forum/2970-read-time-from-bard-fieldtype

When I try this in antlers:

{{ blog_content | flatten | join | strip_tags | read_time:180 }} min read

I get this error:
Error: Array to string conversion

Inside the CMS, at the bottom of the bard field it does show the read time when Im using sets. Not sure if this is helpful but I looked at the source code and its using this package: https://www.npmjs.com/package/read-time-estimate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions