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

Limit characters on <xen:h1>

Discussion in 'XenForo Questions and Support' started by Mike Creuzer, Feb 28, 2012.

  1. Mike Creuzer

    Mike Creuzer Well-Known Member

    Hey all, is there any way I can limit the character count with XenForo? I can do it with Javascript but its kinda a hassle in case their is an easy function.

    Thanks,
    Mike
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> PAGE_CONTAINER

    Replace the red code:

    Code:
    						<xen:hook name="page_container_content_title_bar">
    						<xen:if is="!{$noH1}">						
    							<!-- h1 title, description -->
    							<div class="titleBar">
    								{xen:raw $beforeH1}
    								<h1><xen:if
    									is="{$h1}">{xen:raw $h1}<xen:elseif
    									is="{$title}" />{xen:raw $title}<xen:else
    									/>{$xenOptions.boardTitle}</xen:if></h1>
    								
    								<xen:if is="{$pageDescription.content}"><p id="pageDescription" class="muted {$pageDescription.class}">{xen:raw $pageDescription.content}</p></xen:if>
    							</div>
    						</xen:if>
    						</xen:hook>
    
    Like so:

    Code:
    						<xen:hook name="page_container_content_title_bar">
    						<xen:if is="!{$noH1}">						
    							<!-- h1 title, description -->
    							<div class="titleBar">
    								{xen:raw $beforeH1}
    								<h1><xen:if
    									is="{$h1}">{xen:helper wordtrim, {xen:raw $h1}, 6}<xen:elseif
    									is="{$title}" />{xen:raw $title}<xen:else
    									/>{$xenOptions.boardTitle}</xen:if></h1>
    								
    								<xen:if is="{$pageDescription.content}"><p id="pageDescription" class="muted {$pageDescription.class}">{xen:raw $pageDescription.content}</p></xen:if>
    							</div>
    						</xen:if>
    						</xen:hook>
    
    You can specify the number of characters.
     
    Mike Creuzer likes this.
  3. Mike Creuzer

    Mike Creuzer Well-Known Member

    Thanks Jake, and I know how to do this in PHP, just not really comfortable with the XenForo template helpers yet. But how would I add an ellipsis if the content was cut off?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It already does that.
     
    Mike Creuzer likes this.

Share This Page