I am working with an articles content type. Per usual, there is a content field that stores the body of the article. On a page that links to the articles, I want to display the first paragraph. I am familiar with the truncate to operators. Those are limited to choose a specific number of characters from what I see.
How would I try and grab for example, the first 3 sentences from a post?
That way I could display the summary automatically and not deal with unfinished sentences/clipped words.
Hi there, @mc3digital… this suggestion may not work all that well depending on the length of the sentences, but to grab the first 3 sentences from a post, you could use the :split by operator to split by a period, and then grab the first 3 items from the split using the :items until # operator. Want to give that a try?
As we may have more then one final point type, like “exclamation” and “question marks”, I suggest you to perform a :find and replace of your entire text doing the fallow replacements:
. → #
! → #
? → #
Now you can :split your text by #
Use :Items unitil 3:Number of chacacters to know the length of these 3 first sentences
Use the :truncated to to grab only the first 3 sentences
You set me on the right track to sorting this out! It took me a second to realize what was happening when I was looking for the 2 sentences and it had been converted into one run-on sentence…
I have a nice display now. Here is how I set it up: Parent group's Article's body:split by (.):item #1. Parent group's Article's body:split by (.):item #2.
@rpetribu Thank you for looking into this as well. I like the idea, and may implement this in the future. It is always interesting to consider alternate ways to solve the problem and I see this approach is more flexible as well.