bwakad Posted April 2, 2014 Share Posted April 2, 2014 Is there something available that can limit the characters or preferably words from a field in a template for a list. Or do I have to make 2 fields, one for intro and one for full text, which would not be convenient. Example: List view (index) item one - myfield (20 words) item two - myfield (20 words) Full view (item) my field - full-text Could not really find anything Link to comment Share on other sites More sharing options...
teppo Posted April 2, 2014 Share Posted April 2, 2014 Take a look at mb_substr() for setting character limit. For word limiter you can use something like this: http://snipplr.com/view/12987/limit-words-in-a-string/. // basic mb_substr example $value = $page->my_field; if (mb_strlen($value) > 255) { echo mb_substr($value, 0, 255) . "..."; } else { echo $value; } Link to comment Share on other sites More sharing options...
bwakad Posted April 2, 2014 Author Share Posted April 2, 2014 thanks, I will use both in different conditions! 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