Jump to content

Recommended Posts

Posted

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>

 

Posted

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

  • Like 1
Posted

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
  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...