vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   External Javascript Syndication System (https://vborg.vbsupport.ru/showthread.php?t=267593)

GameExploiters 07-28-2011 11:09 PM

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>

Thanks for your time (:

-GE

kh99 07-29-2011 12:52 AM

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 07-29-2011 04:31 PM

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 :/

http://img600.imageshack.us/img600/9133/errorvc.png

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...

kh99 08-01-2011 03:04 PM

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:

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...

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.


All times are GMT. The time now is 03:53 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01004 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete