Skip to Content Skip to Menu

[SOLVED] Limiting # of chars displayed for a text field in list view

  • startup
  • startup
  • OFFLINE
  • Posts: 113
  • Thanks: 7
  • Karma: 1
  • Add-ons
9 years 7 months ago - 9 years 7 months ago #260690 by startup
Hi,

I have a field say 'description' defined of type text area where members can describe themselves as sort of introduction.

Now, I have setup a CB list that displays members and each row shows the fields for their username, country and description.

I'd like to do so that in the CB list view, only the first 100 characters this description field are displayed. And when a visitor then clicks on the entry and goes to the user's profile page, there he can read the entire length of the description field.

How would I go about setting this up?

I've see in the CB Field manager -> my 'description' field -> Parameters tab -> Layout tab that there is a 'Userlist Value Layout' box. I read this enables 'substitution supported value layout' but I am not sure if / how this could be used to somehow show only the first 100 characters (perhaps followed by '...')

Could you advise on how I could achieve my goal of a field preview in the CB list?

Thank you!
Last edit: 9 years 7 months ago by nant.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
9 years 7 months ago #260740 by krileon
There's no substitution IF statement to count the number of characters nor a substitution to cut it short. Best I can suggest is to use CSS and text-overflow or using a CB Query Field to query for a limited number of characters from the description field column. The CSS example is as follows.

Code:
.cbUserListFC_FIELD_NAME_HERE { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

It works by forcing the text to single line display, setting the max width so it won't overflow its container, then adding overflow handling. You can't really specify how many characters it'll be but it's better than it filling up the page with a very long description.

Another alternative is to use jQuery/JS to modify the DOM after page load. The JS could be added to the page using CB Auto Actions and its Code action.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: startup

Please Log in or Create an account to join the conversation.

  • startup
  • startup
  • OFFLINE
  • Posts: 113
  • Thanks: 7
  • Karma: 1
  • Add-ons
9 years 7 months ago #260783 by startup
Thank you very much1
The following user(s) said Thank You: nant

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum