• 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>

Mike Creuzer

Well-known member
#1
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
 

Jake Bunce

XenForo moderator
Staff member
#2
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

Well-known member
#3
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?