• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Trim the number of characters in member info box

#1
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:



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?
 

Adam K M

Active member
#2
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.
 

Mouth

Well-known member
#5
Try this within extra.css?
div.extraUserInfo dd[itemprop="address"]
{
display: inline-block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: < YOUR AVAILABLE-WIDTH>;
}