XF 1.4 Trim the number of characters in member info box

JackieChun

Well-known member
I would like to limit the number of characters displayed for the "Location" field in the member info in postbit.

The purpose is to avoid lines from carrying over for excessively long fields, like this:

I8OecZ5.jpg


The relevant code in the style is this:

Code:
    <xen:if is="@messageShowLocation AND {$user.location}">
                    <dl class="pairsJustified">
                        <dt>From:</dt>
                        <dd><a href="{xen:link 'misc/location-info', '', 'location={xen:string censor, $user.location, '-'}'}" target="_blank" rel="nofollow" 
                       itemprop="address" class="concealed">{xen:string censor, $user.location}</a></dd>
                    </dl>
                </xen:if>

Can a character limit be introduced into this?
 
Well, there is a way to shorten this without using any xenForo template code.
Measure the amount of space available for your <dd> before it wraps to your next page, and add the following CSS rules to the <dd>
Code:
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: AVAILABLE-WIDTH;

If the location is too long, it will shorten the length to one line and put a "..." to indicate that the line was being shortened.
 
Top Bottom