Display shorten title sentence
4 posts by 2 authors in: Forums > CMS Builder
Last Post: July 15, 2014 (RSS)
By esupport - July 15, 2014
Hi,
Our news title is a long sentence. It is no problem on news section.
How to display shorten title sentence.
For example:
On news section. The full title sentence is "The streets of Berlin turn black, red and gold as thousands of fans welcome Germany home."
How to display the shorten title sentence like "The streets of Berlin turn black, red and gold...(The three dots end of the title)" on Homepage?
Thanks!
Jac
By claire - July 15, 2014
Try this:
echo substr($title, 0, 50) . '...';
This will show the first 50 characters of the title and then add a ... to the end of it.
Claire Ryan
interactivetools.com
Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
By esupport - July 15, 2014
Hi claire
Where to add it?
I triedÂ
<?php echo substr($title, 0, 50) . '...'; ?>
and
<?php echo htmlencode($title, 0, 50) . '...'; ?>
got error "Undefined variable"
By claire - July 15, 2014
You need to change $title to the right variable name - whatever you're using in your code to display this header.
Claire Ryan
interactivetools.com
Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/