Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
limit words in excerpt
I am using the example on docs.textpattern.com/tags/excerpt#example-3-automatically-extract-the-excerpt-from-body-text to limit the number of words showing in excerpts but it nevertheless appears that all excerpts are preceded by p>
<txp:excerpt trim="/^\W*((?:\w+\W+){55})\w.*$/s" replace="$1…" />
Did I break the internet?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: limit words in excerpt
Digging deeper into this and what appears that it is happening <txp:excerpt trim="/^\W*((?:\w+\W+){55})\w.*$/s" replace="$1…" />
trims the opening p tag (<
) and does not add a closing p tag (</p>
). The only way I could solve it was to add the escape="tags"
attribute as in the example.
<p><txp:excerpt escape="tags" trim="/^\W*((?:\w+\W+){55})\w.*$/s" replace="$1…" /></p>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: limit words in excerpt
This is what AI suggests:
<txp:excerpt escape="tags" trim="/^(?:<[^>]+>)*\\W*((?:\\b\\w+\\b\\W+){1,55})\\w*\\b.*$/s" replace="$1…" />
Offline
Re: limit words in excerpt
kuopassa wrote #338635:
This is what AI suggests:
<txp:excerpt escape="tags" trim="/^(?:<[^>]+>)*\\W*((?:\\b\\w+\\b\\W+){1,55})\\w*\\b.*$/s" replace="$1…" />...
Thanks so much, but it does not work. The p tags are misbehaving, and the word limit is not working:(
I’ll stick with what I have for now until I think of anything better.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: limit words in excerpt
Old plugin, still works: rss_auto_excerpt
Offline
Pages: 1