Martinus Posted August 17, 2022 Share Posted August 17, 2022 I searched the forums, API and Docs on Textarea field, but could not find how to limit characters or words in a certain template. I am wondering if there is such a thing in Processwire or do I need to use PHP functions? my code is <p>{item->summary}</p> Link to comment Share on other sites More sharing options...
Jan Romero Posted August 17, 2022 Share Posted August 17, 2022 To limit how many characters can be input, to go the field settings and set "maximum length" in the Input tab to a value greater than 0. You can also do this per template if you switch to a template using the dropdown in the upper right corner. Or you can go to the template settings and click the field there. To shorten the string during output, you can use WireTextTools: WireTextTools::truncate() method - ProcessWire API 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted August 17, 2022 Share Posted August 17, 2022 You can either use the $sanitizer->truncate() in your template file or set a character limit from within your template settings. For the second option go to: Setup > Templates > Your Template Click on the textarea field (summary) > Switch to Tab: Inputs > Set character limit 1 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