Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 2212 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Should be simple...

Thread title: Should be simple...
Closed Thread    
    Thread tools Search this thread Display Modes  
10-30-2008, 03:54 PM
#1
Seb is offline Seb
Seb's Avatar
Status: Watermelon Man
Join date: Nov 2006
Location: London
Expertise:
Software:
 
Posts: 3,312
iTrader: 36 / 100%
 

Seb is on a distinguished road

  Old  Should be simple...

...but I'm clueless.

What I would like to know, is how can I get text, when over certain number of characters to shorten to add ... at the end.

You should be able to see what I mean here in the "Latest Blog Posts" section:

http://www.sebspad.com/

Instead of it cutting to the next line, I want it to stay on one line, but add ... at the end.

Help is appreciated!

10-30-2008, 04:05 PM
#2
creativejen is offline creativejen
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
 
Posts: 2,353
iTrader: 25 / 96%
 

creativejen is an unknown quantity at this point

Send a message via MSN to creativejen

  Old

$title = $_POST['title'];

$text = substr($title,0,100);

echo "$text" . "...";

This would only show the first 100 characters.

10-31-2008, 12:07 AM
#3
Seb is offline Seb
Seb's Avatar
Status: Watermelon Man
Join date: Nov 2006
Location: London
Expertise:
Software:
 
Posts: 3,312
iTrader: 36 / 100%
 

Seb is on a distinguished road

  Old

Thanks, but I have no idea how I would integrate this with the Wordpress plugin "Recent Posts". If anyone is familiar with it and knows how I could do so, that would be great.

Edit: Actually, I think I found out how to do it in the documentation. Thanks!

11-03-2008, 08:06 PM
#4
Geert is offline Geert
Geert's Avatar
Status: Junior Member
Join date: Mar 2005
Location: Belgium
Expertise:
Software:
 
Posts: 67
iTrader: 0 / 0%
 

Geert is on a distinguished road

Send a message via Skype™ to Geert

  Old

Originally Posted by enigma View Post
$text = substr($title,0,100);

Note that substr() is not UTF-8 compatible and can screw up non-ascii characters. Instead use mb_substr().

And if you are interested in a function that will preserve full words, I created text::limit_chars() for Kohana long time ago: http://dev.kohanaphp.com/browser/tru...p?rev=3366#L40

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed