|
HOW TO TRUNCATE HEADLINES ?
|
| Author |
Message |
david M
Junior Member
 
Posts: 7
Group: Registered
Joined: Nov 2006
Status:
Offline
Reputation: 0
|
HOW TO TRUNCATE HEADLINES ?
Hello,
I would like to display only the first 20 (or n number) of characters of each headline news on my home page ? Could you tell me please how to do this, since the standard configuration displays the whole headline and therefore displays in on two lines if it is too long.
Thanks a lot.
David
|
|
| 11-07-2006 08:41 PM |
|
 |
Brian
Administrator
      
Posts: 122
Group: Administrators
Joined: Jan 2006
Status:
Offline
Reputation: 0
|
RE: HOW TO TRUNCATE HEADLINES ?
When you go into the Main Settings, there should be a setting like this:
Maximum News Length
If you have news truncation enabled, this is the approximate number of characters to display before providing a link to read the rest.
Brian Earley
Utopia Software
utopiasupport@gmail.com
http://www.utopiasoftware.net
Software: Utopia News Pro
|
|
| 11-07-2006 11:11 PM |
|
 |
david M
Junior Member
 
Posts: 7
Group: Registered
Joined: Nov 2006
Status:
Offline
Reputation: 0
|
RE: HOW TO TRUNCATE HEADLINES ?
Hi brian
No, this is not what I wanted to do...
Suppose on the home page i have the following headlines
- Briton jailed for 40 years over U.S. and UK plots
- Fight for U.S. Congress up to voters now
- Rwanda seeks four genocide fugitives from Britain
- Soldier killed in attack on Basra base
- British and American hostages freed in Nigeria
- Reid orders offenders' bail hostels review
- Religious leaders unite to launch vaccine bond
What I would like is to display it like that
- Briton jailed for 40 years...
- Fight for U.S. Congress...
- Rwanda seeks four...
- Soldier killed in attack...
- British and American...
- Reid orders offenders'...
- Religious leaders unite...
of course, clicking on the headline brings you to the page where you can read the full news.
What you were talking about was News Length... I want to apply that to the headlines.
Thanks
David
|
|
| 11-07-2006 11:55 PM |
|
 |
Brian
Administrator
      
Posts: 122
Group: Administrators
Joined: Jan 2006
Status:
Offline
Reputation: 0
|
RE: HOW TO TRUNCATE HEADLINES ?
I see what you're saying. This is for within headlines.php, right?
Find:
$poster = $headlines['poster'];
Add under it:
$cutstring = md5(time()); $subject = wordwrap($subject, 50, $cutstring); $subject = explode($cutstring, $subject); $subject = $subject[0];
You can then adjust the 50 to different lengths. I believe this will work.
Brian Earley
Utopia Software
utopiasupport@gmail.com
http://www.utopiasoftware.net
Software: Utopia News Pro
This post was last modified: 11-08-2006 01:33 AM by Brian.
|
|
| 11-08-2006 01:33 AM |
|
 |
david M
Junior Member
 
Posts: 7
Group: Registered
Joined: Nov 2006
Status:
Offline
Reputation: 0
|
RE: HOW TO TRUNCATE HEADLINES ?
Hi Brian
Thanks a lot, it works perfectly
PS : One more thing. And if I want to add the '...' (suspension points) after the truncation, (eg: like in my example above), where do I put that in the code ?
Dave
This post was last modified: 11-08-2006 07:46 AM by david M.
|
|
| 11-08-2006 07:40 AM |
|
 |
david M
Junior Member
 
Posts: 7
Group: Registered
Joined: Nov 2006
Status:
Offline
Reputation: 0
|
RE: HOW TO TRUNCATE HEADLINES ?
OOps, I forgot to say that i would like the suspension points to display ONLY if the headline is truncated (eg : longer than 50 characters).
If smaller (<50 characters), I don't want the suspension points to display since the headline is complete.
If you have any idea, that would be great.
Thx
Dave
|
|
| 11-08-2006 06:28 PM |
|
 |
Brian
Administrator
      
Posts: 122
Group: Administrators
Joined: Jan 2006
Status:
Offline
Reputation: 0
|
RE: HOW TO TRUNCATE HEADLINES ?
That should be easy. Replace the first code with:
$cutstring = md5(time()); $subjectinit = $subject; $subject = wordwrap($subject, 50, $cutstring); $subject = explode($cutstring, $subject); if (strlen($subjectinit) == strlen($subject)) { $subject = $subject[0]; } else { $subject = $subject[0].'...'; }
If this doesn't work, let me know. It would probably be because of the way strlen works on wordwrap'd things. I'd just have to change it up a bit.
Brian Earley
Utopia Software
utopiasupport@gmail.com
http://www.utopiasoftware.net
Software: Utopia News Pro
This post was last modified: 11-08-2006 11:14 PM by Brian.
|
|
| 11-08-2006 11:13 PM |
|
 |