Neo Posted June 9, 2015 Share Posted June 9, 2015 I had a few situations were I needed to limit the output of a textarea-field to e.g. 150 characters and / or strip all html-tags to work with plain text. I used the sanitizer-function like in the following example: <?php // Echo the latest 3 items on homepage foreach($pages->get("/services/")->children("limit=3, sort=-created") as $service){ // sanitizer options $options = array( // maximum allowed characters for multibyte strings 'maxLength' => 150, ); $service_preview = $sanitizer->textarea($service->body, $options); echo '<div class="one-third column">'; echo '<article class="icon-box">'; echo '<h3>'.$service->title.'</h3>'; echo '<p>'.$service_preview.'... </p>'; echo '</article>'; echo '</div>'; } ?> Is that the only way to limit character-output of a textarea? Link to comment Share on other sites More sharing options...
Soma Posted June 9, 2015 Share Posted June 9, 2015 Enter that in Google. "processwire limit character output" You're welcome Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now