seo-pro icon indicating copy to clipboard operation
seo-pro copied to clipboard

Error in Documentation or Bug with Antlers Code as Description

Open sewid opened this issue 1 year ago • 8 comments

In the seo pro docs, there is an example for antlers templating:

{{ content | strip_tags | truncate:250:... }}

If I use this example code or if I use the code below as description content:

{{ content | strip_tags | truncate(150, '...') }}

I get this error message:

strip_tags(): Argument #1 ($string) must be of type string, array given

Statamic Version is: 4.10.2 SEO Pro Version is: 5.2.1

sewid avatar Jul 13 '23 12:07 sewid

This would work if your content is a string, but my guess is you're using Bard, which stores its data in an array. In order to truncate Bard text you'd need to loop the tag, get the first text var, and truncate that.

jackmcdade avatar Jul 13 '23 12:07 jackmcdade

Hi @jackmcdade , no, it's a markdown field. If I place

{{ content | strip_tags | truncate(150, '...') }}

in a template somewhere, it works without problems.

sewid avatar Jul 13 '23 12:07 sewid

Which Antlers parser are you using? You can check in config/statamic/antlers.php – you should be using runtime.

jackmcdade avatar Jul 13 '23 12:07 jackmcdade

it is runtime

sewid avatar Jul 13 '23 12:07 sewid

Okay, I'm gonna have @jesseleite take a look at this, he's the SEO Pro guy and it's clear that something else is at play here 🤔

jackmcdade avatar Jul 13 '23 13:07 jackmcdade

ok, thanks! 😄

sewid avatar Jul 13 '23 13:07 sewid

Hey @sewid, I'm having reproducing this with a markdown field 🤔 Could you maybe provide a simple example site repo with the issue reproduced that we could pull down by chance?

jesseleite avatar Aug 04 '23 20:08 jesseleite

Hey @jesseleite, I've sent you an email about two weeks ago where you can find the code. Have you seen it?

sewid avatar Aug 16 '23 05:08 sewid