The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
External Javascript Syndication System
So I'm using this Javascript to list the newest threads on the front page of my site, except I've noticed that longer thread titles end up pushing the entire site off.
So how do i limit the thread title characters and how do i have the poster instead of time of the post display ? I currently use this code: Code:
<script type="text/javascript" src="http://www.My-Site.net/forum/external.php?type=js"></script> <script type="text/javascript"> <!-- for (var i = 0; i < threads.length; i++) { document.write ('<a href="http://www.My-Site.net/forum/showthread.php?t=' + threads[i]['threadid'] + '"> <span style="color:#FFFF00"> ' + ' <img src="images/star.png" alt="star icon"/> ' + threads[i]['title'] + ' </span> </a> <em>Posted on: ' + threads[i]['threaddate'] + '</em><br />'); } //--> </script> -GE |
#2
|
|||
|
|||
Try this:
Code:
<script type="text/javascript" src="http://localhost/forum4/external.php?type=js"></script> <script type="text/javascript"> <!-- var maxlen = 30; for (var i = 0; i < threads.length; i++) { var title = (threads[i]['title'].length > maxlen ? threads[i]['title'].substr(1, maxlen - 3) + "..." : threads[i]['title']); document.write ('<a href="http://www.My-Site.net/forum/showthread.php?t=' + threads[i]['threadid'] + '"> <span style="color:#FFFF00"> ' + ' <img src="images/star.png" alt="star icon"/> ' + title + ' </span> </a> <em>Posted by: ' + threads[i]['poster'] + '</em><br />'); } //--> </script> of course you should change maxlen to whatever you want. |
Благодарность от: | ||
GameExploiters |
#3
|
|||
|
|||
Thank you very much!
--------------- Added [DATE]1311974969[/DATE] at [TIME]1311974969[/TIME] --------------- I found an error with your code, it cuts off the first letter off the thread :/ It's supposed to say 'ReQ is done and..' Also how to make it output the first 200 characters of a thread ? Is there a online document with all the "threads[i]['poster']" things ? Cause the one from vBulletin lacks a LOT of information... |
#4
|
|||
|
|||
Sorry about that - there should be a '0' instead of '1' in the substr call:
Code:
<script type="text/javascript" src="http://localhost/forum4/external.php?type=js"></script> <script type="text/javascript"> <!-- var maxlen = 30; for (var i = 0; i < threads.length; i++) { var title = (threads[i]['title'].length > maxlen ? threads[i]['title'].substr(0, maxlen - 3) + "..." : threads[i]['title']); document.write ('<a href="http://www.My-Site.net/forum/showthread.php?t=' + threads[i]['threadid'] + '"> <span style="color:#FFFF00"> ' + ' <img src="images/star.png" alt="star icon"/> ' + title + ' </span> </a> <em>Posted by: ' + threads[i]['poster'] + '</em><br />'); } //--> </script> Quote:
I just look at the external.php file to see what it's doing. In the case of a javascript output it only provides threadid, title, poster, date, time. You could probably modify external.php to provide more (I don't think it can be done with plugins, you'd havew to edit the file. In any case, the JS output section is around line 403. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|