Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2011, 11:09 PM
GameExploiters GameExploiters is offline
 
Join Date: Feb 2010
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 07-29-2011, 12:52 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Благодарность от:
GameExploiters
  #3  
Old 07-29-2011, 04:31 PM
GameExploiters GameExploiters is offline
 
Join Date: Feb 2010
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #4  
Old 08-01-2011, 03:04 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 08:42 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03752 seconds
  • Memory Usage 2,195KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (1)post_thanks_box_bit
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete