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 12-06-2009, 05:34 PM
vaskies vaskies is offline
 
Join Date: Dec 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default RESOLVED: Vbulletin Variable / Array names in Javascript?

*warning* javascript/php noob here. I'm in the process of learning, but would *HIGHLY* appreciate some help on this. The bolded code is what I'm editing:
(note I'm using wz_tooltip.js, a javascript tooltip and the how to display active threads on forum home

Code:
<script type="text/javascript" src="/js/tooltips/wz_tooltip.js"></script>
<if condition="$vbulletin->options['externaljs']">
<!-- show latest active threads -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" 
align="center">
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_external')"><img 
id="collapseimg_forumhome_external" 
src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_external].gif" alt="" border="0" /></a>
<a href="search.php?$session[sessionurl]do=getnew">Latest Active Threads</a>
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_external" style="$vbcollapse[collapseobj_forumhome_external]">
<tr>
 
<td class="alt1" width="100%">
 
<div class="smallfont">
<script type="text/javascript" src="external.php?type=js"></script> 
<script language="" type="text/javascript">
<!--
for (var x in threads)
{
document.writeln("<img class=\"inlineimg\" src=\"$stylevar[imgdir_button]/lastpost.gif\" alt=\"\" border=\"0\" /> 
<a onmouseover=\"Tip('<b>Thread Title:</b> $threadinfo[title]<br/>
<b>Last Post Time:</b> $gnpdate<br/>
<b>Username of Last Poster:</b>$threadinfo[musername]<br/>
<b>Preview of Thread:</b>$threadinfo[preview]')\" onmouseout=\"UnTip()\" href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a><br />");
}
//-->
</script></div>
 
</td>
</tr>
</tbody>
<!-- show latest active threads -->
</table>
<br />
</if>
As it is, nothing shows up in the tooltip. What's wrong with my variables? Thank you very much in advance!
Reply With Quote
  #2  
Old 12-06-2009, 07:37 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow, *there's* a cool puzzle. Anyway, too cool for me maybe because I don't see anything wrong. I can't remember, if you view the HTML source will you see the part that comes from a document.write? The only other thing I can think of is to simplify it, just put in <a onmouseover="Tip('foo')" ... and then add stuff back in gradually.
Reply With Quote
  #3  
Old 12-07-2009, 12:29 AM
vaskies vaskies is offline
 
Join Date: Dec 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Viewing source with ('Some Text') as the mouseover:
Code:
<!--
for (var x in threads)
{
document.writeln("<img class=\"inlineimg\" src=\"images/buttons/lastpost.gif\" alt=\"\" border=\"0\" /> <a onmouseover=\"Tip('Some text')\" onmouseout=\"UnTip()\" href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a><br />");
}
//-->
</script>
When replacing Some Text with say, $gnpdate, this is what view source outputs:

Code:
<!--
for (var x in threads)
{
document.writeln("<img class=\"inlineimg\" src=\"images/buttons/lastpost.gif\" alt=\"\" border=\"0\" /> <a onmouseover=\"Tip('')\" onmouseout=\"UnTip()\" href=\"showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a><br />");
}
//-->
Where the variable was placed, nothing shows up at all. And on the mouse over, it is blank as well.

Reply With Quote
  #4  
Old 12-07-2009, 01:07 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think that could only happen if $gnpdate had no value.
Reply With Quote
  #5  
Old 12-07-2009, 01:19 AM
vaskies vaskies is offline
 
Join Date: Dec 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What's interesting to note is that a variable like $bbuserinfo[musername] works!

None of the variables directly related to the individual thread though are working.

Is there a way I could go about assigning them proper values?
Reply With Quote
  #6  
Old 12-07-2009, 01:44 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know what $gnpdate is supposed to be. Is it set in the same php file that the template is eval'd in?
Reply With Quote
  #7  
Old 12-07-2009, 02:10 AM
vaskies vaskies is offline
 
Join Date: Dec 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oops, I got confused there for a second. I've been trying various plugins throughout the day and I thought that was a default vbulletin variable.

I'm trying to display the date of the last post of a thread. So when you mouse over the thread link, it will display "Last Post: 10 minutes ago".

How would I go about defining that?
Reply With Quote
  #8  
Old 12-07-2009, 04:52 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just the date, or those other thread fields? Anyway, if you look in forumdisplay.php you'll see how the thread info is read from the database, then I think includes/functions_forumdisplay.php has functions for formatting that data. If you search in there for 'dateline' you'll find where it uses the function vbdate() to do the formatting.

It depends on which .php file you're displaying, but it looks like in general $threadinfo is set by global.php if the url has a threadid. In forumdisplay it's displaying many threads in a loop, and it looks like within that loop it's using $thread. So if your stuff is being call from there you might find that $thread[postdate] and $thread[posttime] are already set.
Reply With Quote
  #9  
Old 12-08-2009, 12:02 AM
vaskies vaskies is offline
 
Join Date: Dec 2009
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Both $thread[postdate] and $thread[posttime] show up as nothing. There seems to be no association with those variables and the thread link itself. Maybe I have to read it from the database? (I have no idea how I'd do that )
Reply With Quote
  #10  
Old 12-08-2009, 10:42 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, where are you getting the thread titles? What's the url of the page you are working on (not the domain name, but everything after that)?
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 05: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.04320 seconds
  • Memory Usage 2,255KB
  • 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
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete