The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I'm using the following code to display the latest threads in my footer, however I'd like to limit the number of characters that are shown in the Thread title.
Can anyone show me what needs to be changed to say limit it to the first 20 or so characters? Code:
<script type="text/javascript" src="http://www.mydomain.com/external.php?type=js"></script> <script type="text/javascript"> <!-- for (var i = 0; i < threads.length; i++) { document.write('<li><a href="http://www.mydomain.com/showthread.php?t=' + threads[i]['threadid'] + '" title="' + threads[i]['title'] + '">' + threads[i]['title'] + '</a></li>'); } //--> </script> |
#2
|
||||
|
||||
![]()
You're looking for substring.
Code:
<script type="text/javascript" src="http://www.mydomain.com/external.php?type=js"></script> <script type="text/javascript"> <!-- for (var i = 0; i < threads.length; i++) { document.write('<li><a href="http://www.mydomain.com/showthread.php?t=' + threads[i]['threadid'] + '" title="' + threads[i]['title'] + '">' + threads[i]['title'].substr(0, 20) + '</a></li>'); } //--> </script> Code:
<script type="text/javascript" src="http://www.mydomain.com/external.php?type=js"></script> <script type="text/javascript"> <!-- for (var i = 0; i < threads.length; i++) { var url = '<li><a href="http://www.mydomain.com/showthread.php?t=' + threads[i]['threadid'] + '" title="' + threads[i]['title'] + '">'; if(threads[i]['title'].length > 20) { url += threads[i]['title'].substr(0, 20) + '...'; } else { url += threads[i]['title']; } url += '</a></li>'; document.write(url); } //--> </script> |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|