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 04-25-2012, 11:05 PM
MikeJDance MikeJDance is offline
 
Join Date: Feb 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Show Thread Description :(

I have this code:

<script language="" type="text/javascript">
var name1 = new String();
var title1 = new String();
for (x = 0; x < 4; x++){
name1 = threads[x].poster;
if (name1.length > 13){
name1 = name1.slice(0,9) + "&hellip;";
}
title1 = threads[x].title;
if (title1.length > 28){
title1 = title1.slice(0,25) + "&hellip;";
}
document.writeln("<a href=\"http://www.habbohotelforum.net/showthread.php?t="+threads[x].threadid+"\" target=\"_blank\" class=\"forumtitle\">"+title1+" »</a><br /><div style=\"padding-bottom: 5px;\"><em>+description+(Posted by "+name1+")</em></div>");}
</script>

I'm trying to add the description about 26 characters of the first post please. I'm having problems.

Also i'm using 3.8.7 SP2

Thank you for any help provided.
Reply With Quote
  #2  
Old 04-25-2012, 11:12 PM
ForceHSS ForceHSS is offline
 
Join Date: Apr 2008
Posts: 6,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

and the problem would be?
Reply With Quote
Благодарность от:
MikeJDance
  #3  
Old 04-26-2012, 01:07 AM
MikeJDance MikeJDance is offline
 
Join Date: Feb 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ForceHSS View Post
and the problem would be?
It's not picking up the post, just the title and the Poster
Reply With Quote
  #4  
Old 04-26-2012, 02:06 AM
ForceHSS ForceHSS is offline
 
Join Date: Apr 2008
Posts: 6,357
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

a screenshot or a link
Reply With Quote
  #5  
Old 04-26-2012, 10:42 AM
MikeJDance MikeJDance is offline
 
Join Date: Feb 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ForceHSS View Post
a screenshot or a link
Reply With Quote
  #6  
Old 04-26-2012, 11:19 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you using external.php with type=js? The output doesn't include any info from the post. You would need to modify external.php or else come up with another way to get the post text.
Reply With Quote
  #7  
Old 04-26-2012, 11:49 AM
MikeJDance MikeJDance is offline
 
Join Date: Feb 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Are you using external.php with type=js? The output doesn't include any info from the post. You would need to modify external.php or else come up with another way to get the post text.
yes i am mate. What could i put in it for it to get the text?
Reply With Quote
  #8  
Old 04-26-2012, 01:39 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In external.php around line 409, try replacing the entire "if type is js" block with this:

Code:
if ($vbulletin->GPC['type'] == 'JS')
{ // javascript output
	$output = "
	function thread(threadid, title, poster, threaddate, threadtime, preview)
	{
		this.threadid = threadid;
		this.title = title;
		this.poster = poster;
		this.threaddate = threaddate;
		this.threadtime = threadtime;
		this.preview = preview;
	}
	";
	$output .= "var threads = new Array(" . sizeof ($threadcache) . ");\r\n";
	if (!empty($threadcache))
	{
		require_once(DIR . '/includes/class_bbcode_alt.php');
		foreach ($threadcache AS $threadnum => $thread)
		{
			$thread['title'] = addslashes_js(htmlspecialchars_uni($thread['prefix_plain']) . $thread['title']);
			$thread['poster'] = addslashes_js($thread['postusername']);
			$plaintext_parser = new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list($vbulletin->options['bburl'] . '/'));
			$preview = $plaintext_parser->parse($thread['message'], $thread['forumid']);
			unset($plaintext_parser);
                        if (strlen($preview) > 23) $preview = substr($preview, 0, 23) . "...";
                        $preview = addslashes_js($preview);
			$output .= "\tthreads[$threadnum] = new thread($thread[threadid], '$thread[title]', '$thread[poster]', '" . addslashes_js(vbdate($vbulletin->options['dateformat'], $thread['dateline'])) . "', '" . addslashes_js(vbdate($vbulletin->options['timeformat'], $thread['dateline'])) . "', '" .
$preview . "');\r\n";
		}
	}
}

Then you should be able to use thread[x].preview in your js code. You might want to comment out the existing if block so you can easily bring it back if needed.

BTW, I put the length limiting code in the php so you don't need to check in your js. Or if you'd rather have it in the js you can of course remove that line from the php.
Reply With Quote
  #9  
Old 04-26-2012, 02:03 PM
MikeJDance MikeJDance is offline
 
Join Date: Feb 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
In external.php around line 409, try replacing the entire "if type is js" block with this:

Code:
if ($vbulletin->GPC['type'] == 'JS')
{ // javascript output
	$output = "
	function thread(threadid, title, poster, threaddate, threadtime, preview)
	{
		this.threadid = threadid;
		this.title = title;
		this.poster = poster;
		this.threaddate = threaddate;
		this.threadtime = threadtime;
		this.preview = preview;
	}
	";
	$output .= "var threads = new Array(" . sizeof ($threadcache) . ");\r\n";
	if (!empty($threadcache))
	{
		require_once(DIR . '/includes/class_bbcode_alt.php');
		foreach ($threadcache AS $threadnum => $thread)
		{
			$thread['title'] = addslashes_js(htmlspecialchars_uni($thread['prefix_plain']) . $thread['title']);
			$thread['poster'] = addslashes_js($thread['postusername']);
			$plaintext_parser = new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list($vbulletin->options['bburl'] . '/'));
			$preview = $plaintext_parser->parse($thread['message'], $thread['forumid']);
			unset($plaintext_parser);
                        if (strlen($preview) > 23) $preview = substr($preview, 0, 23) . "...";
                        $preview = addslashes_js($preview);
			$output .= "\tthreads[$threadnum] = new thread($thread[threadid], '$thread[title]', '$thread[poster]', '" . addslashes_js(vbdate($vbulletin->options['dateformat'], $thread['dateline'])) . "', '" . addslashes_js(vbdate($vbulletin->options['timeformat'], $thread['dateline'])) . "', '" .
$preview . "');\r\n";
		}
	}
}

Then you should be able to use thread[x].preview in your js code. You might want to comment out the existing if block so you can easily bring it back if needed.

BTW, I put the length limiting code in the php so you don't need to check in your js. Or if you'd rather have it in the js you can of course remove that line from the php.
Thank you mate

--------------- Added [DATE]1335461255[/DATE] at [TIME]1335461255[/TIME] ---------------

I've changed external.php code to:

Code:
if ($vbulletin->GPC['type'] == 'JS')
{ // javascript output
$output = "
function thread(threadid, title, poster, threaddate, threadtime, preview)
{
this.threadid = threadid;
this.title = title;
this.poster = poster;
this.threaddate = threaddate;
this.threadtime = threadtime;
this.preview = preview;
}
";
$output .= "var threads = new Array(" . sizeof ($threadcache) . ");\r\n";
if (!empty($threadcache))
{
require_once(DIR . '/includes/class_bbcode_alt.php');
foreach ($threadcache AS $threadnum => $thread)
{
$thread['title'] = addslashes_js(htmlspecialchars_uni($thread['prefix_plain']) . $thread['title']);
$thread['poster'] = addslashes_js($thread['postusername']);
$plaintext_parser = new vB_BbCodeParser_PlainText($vbulletin, fetch_tag_list($vbulletin->options['bburl'] . '/'));
$preview = $plaintext_parser->parse($thread['message'], $thread['forumid']);
unset($plaintext_parser);
if (strlen($preview) > 23) $preview = substr($preview, 0, 23) . "...";
$preview = addslashes_js($preview);
$output .= "\tthreads[$threadnum] = new thread($thread[threadid], '$thread[title]', '$thread[poster]', '" . addslashes_js(vbdate($vbulletin->options['dateformat'], $thread['dateline'])) . "', '" . addslashes_js(vbdate($vbulletin->options['timeformat'], $thread['dateline'])) . "', '" .
$preview . "');\r\n";
}
}
}
And then my code for the script would be:

Code:
<script language="" type="text/javascript">
var name1 = new String();
var title1 = new String(); 
for (x = 0; x < 4; x++){
if (name1.length > 13){
name1 = name1.slice(0,9) + "&hellip;";
}
preview1 = thread[x].preview;
if (preview1.length > 26){
preview1 = preview1.slice(0,25) + "&hellip;";
preview1 = thread[x].preview;
}
if (title1.length > 26){
title1 = title1.slice(0,25) + "&hellip;";
}
document.writeln("<a href=\"http://www.habbolandforum.net/showthread.php?t="+threads[x].threadid+"\" target=\"_blank\">"+title1+"</a><br /><div style=\"padding-bottom: 5px;\"><em>"+preview1+"</em></div>");}
</script>

It just shows nothing.
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 12:16 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.04679 seconds
  • Memory Usage 2,252KB
  • Queries Executed 11 (?)
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
  • (4)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (1)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_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