Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 14 Jan 2009, 14:37
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Trimming thread title at end of a cell rather than at specific number of characters

I am currently using a function which trims the thread title automatically after a specified number of characters in the title. Since the thread-title is displayed in a table-cell with a percentage width, the cell automatically expands depending on the size of the screen. I would therefore like to use a function that will trim the thread-title whenever the title reaches the end of the cell, rather than at a fixed position after a certain number of characters. How can I do this?

Here is the code to the current function:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by sparklywater; 14 Jan 2009 at 19:48.
Reply With Quote
  #2  
Old 14 Jan 2009, 14:42
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
You can't do that. Every browser renders a page differently and the table cell width is very often dependent and other table cell widths also. There is no way to figure out what the width of the cell is going to be prior to it being rendered. And even then, sometimes you see it expand/contract right before your eyes.
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #3  
Old 14 Jan 2009, 17:46
Bellardia Bellardia is offline
 
Join Date: Jul 2007
Only way to do this is with javascript.
PHP is static, you can't change how something looks after the page loads.
Reply With Quote
  #4  
Old 14 Jan 2009, 19:48
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Originally Posted by Bellardia View Post
Only way to do this is with javascript.
PHP is static, you can't change how something looks after the page loads.
Any idea what javascript I can use?

thanks.
Reply With Quote
  #5  
Old 15 Jan 2009, 05:01
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
Originally Posted by Bellardia View Post
Only way to do this is with javascript.
PHP is static, you can't change how something looks after the page loads.
However, I don't think you can fetch the width of a displayed cell in Javascript. The width as defined in the source code may be fetchable, but the width (in pixels) that it is currently displayed cannot.
__________________
Former vBulletin.org Staff Member

View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #6  
Old 15 Jan 2009, 07:45
sparklywater sparklywater is offline
 
Join Date: Jun 2008
Originally Posted by Dismounted View Post
However, I don't think you can fetch the width of a displayed cell in Javascript. The width as defined in the source code may be fetchable, but the width (in pixels) that it is currently displayed cannot.
Well, it doesn't necessarily have to determine the width of the cell in pixels. I was wondering if there is a function which can determine when a text is flowing onto a new line, because this is what happens when the text hits the end of a cell, it moves onto a new line on the screen. So there won't be any need to work out the width of the cell. If a function can tell that the width of the cell has caused the text to flow onto another line, it can trim the string at that point to make it fit on one line.

Not sure if this is too much to ask, but may be possible somehow.
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Posting Features Minimum Characters Per Thread Title Atakan KOC vBulletin 3.6 Add-ons 13 13 Nov 2014 11:38



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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 15:49.

Layout Options | Width: Wide Color: