1. 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

Discussion in 'Styling and Customization Questions' started by JackieChun, Jun 30, 2015.

  1. JackieChun

    JackieChun Active 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:

    [​IMG]

    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?
     
  2. Adam K M

    Adam K M Active Member

    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.
     
  3. JackieChun

    JackieChun Active Member

    I see what you're getting at, but I only want to trim the location field and allow lines in other fields to carry over.
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Change:
    Code:
    {xen:string censor, $user.location}
    To:
    Code:
    {xen:helper snippet, {xen:string censor, $user.location}, 10}
    Adjust the value to suit.
     
    tommydamic68 and JackieChun like this.
  5. Mouth

    Mouth Well-Known Member

    Try this within extra.css?
     

Share This Page