New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

String modifiers... with math

Daniel Edwards April 4, 2020 by Daniel Edwards

Alrighty. I'm attempting to do something that in theory should be simple but actually has become pretty complicated.

I have a string, and it's a long string. (~900 characters). In the CP my client can modify this, and put whatever they want there, so the string isn't a fixed length.

I want to split the string in half (without cutting words), and display both halves in separate columns within the template.

My research so far has been unfruitful, but I imagine it'll use some combination of length, divide, and safe_truncate.

Something like:
{{ article text | safe_truncate:length divide="2" }}
And then something similar for the second half...

So far, I've been unable to get the math modifiers working on the string (probably because, you know, it's a string...).

Any help or suggestions?

Answered by Erin Dalzell!
>>>>>>> Answered <<<<<<<
3 Replies