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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2013, 02:33 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help me show

I use the following code inserted hook forumbit_display and it has taken time of the last post, now I need to get the time of the first post (time when create topic), anyone can help me, thanks a lot.

PHP Code:
$thread['dateline'] = vbdate($vbulletin->options['op_date_format'], $lastpostinfo['lastpost']);
$lastpostinfo['trimthread'] = '['.$thread['dateline'].'] '.$lastpostinfo['trimthread']; 
Reply With Quote
  #2  
Old 01-22-2013, 02:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The information on the last post is saved in the forum table, but what you want isn't there so you'd have to add a query to get it.
Reply With Quote
  #3  
Old 01-22-2013, 03:01 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can guide me to select the table and should have what conditions? Please give me an example.

SELECT * what ?
WHERE ?
Reply With Quote
  #4  
Old 01-22-2013, 03:18 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually now that I've looked at some more code, I think you can piggy back it on another query so you don't have to add one. To try that, create a new plugin using hook cache_ordered_forums and code like this:
Code:
$counter_select .= ', thread.dateline AS lastthreaddateline ';
$tachyjoin .= ' LEFT JOIN ' . TABLE_PREFIX . 'thread AS thread ON(lastthreadid = thread.threadid)';

and then you should be able to use $forum['lastthreaddateline'] in your plugin (but I haven't tried it at all).


Edit: ...but I'm not sure if that's right now that I think about it. I don't know if the lastthreadid is the last thread created or the last thread that someone posted in.
Reply With Quote
  #5  
Old 01-22-2013, 03:33 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Actually now that I've looked at some more code, I think you can piggy back it on another query so you don't have to add one. To try that, create a new plugin using hook cache_ordered_forums and code like this:
Code:
$counter_select .= ', thread.dateline AS lastthreaddateline ';
$tachyjoin .= ' LEFT JOIN ' . TABLE_PREFIX . 'thread AS thread ON(lastthreadid = thread.threadid)';

and then you should be able to use $forum['lastthreaddateline'] in your plugin (but I haven't tried it at all).

I have to try and error
Code:
Database error in vBulletin 4.2.0:

Invalid SQL:


				SELECT subscribeforumid, forum.forumid, forum.lastpost, forum.lastposter, forum.lastposterid, forum.lastthread, forum.lastthreadid, forum.lasticonid, forum.threadcount, forum.replycount, forum.lastpostid, forum.lastprefixid, thread.threadid, thread.field6 AS field6, thread.field7 AS field7, thread.dateline AS lastthreaddateline , user.usergroupid, user.homepage, user.options AS useroptions, IF(userlist.friend = 'yes', 1, 0) AS isfriend,
					user.lastactivity, user.lastvisit, IF(user.options & 512, 1, 0) AS invisible
					
				FROM forum AS forum
				LEFT JOIN subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = 1)
				
				LEFT JOIN user AS user ON (user.userid = forum.lastposterid)
				LEFT JOIN userlist AS userlist ON (userlist.relationid = user.userid AND userlist.type = 'buddy' AND userlist.userid = 1)
				 LEFT JOIN thread AS thread ON (thread.threadid=forum.lastthreadid) LEFT JOIN thread AS thread ON(lastthreadid = thread.threadid);

MySQL Error   : Not unique table/alias: 'thread'
Error Number  : 1066
Request Date  : Wednesday, January 23rd 2013 @ 12:31:43 AM
Error Date    : Wednesday, January 23rd 2013 @ 12:31:43 AM
Script        : http://localhost/forum.php
Referrer      : http://localhost/showthread.php?t=571&p=815
IP Address    : 123.19.70.155
Username      : Admin
Classname     : vB_Database
MySQL Version : 5.3.8-MariaDB

Stack Trace:

#0 vB_Database->halt() called in [path]\includes\class_core.php on line 426
#1 vB_Database->execute_query() called in [path]\includes\class_core.php on line 473
#2 vB_Database->query_read_slave() called in [path]\includes\functions.php on line 4901
#3 cache_ordered_forums() called in [path]\forum.php on line 594

and use code
PHP Code:
"SELECT lastthreaddateline FROM " TABLE_PREFIX "thread WHERE threadid = " $forum['lastthreadid'
Code:
Unknown column 'lastthreaddateline' in 'field list'
Reply With Quote
  #6  
Old 01-22-2013, 03:38 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oops, it looks like you already have another plugin doing something similar? Try commenting out the $tachyjoin line in the code I posted and see if that works (although it seems like it's not quite correct since forum.lastthreadid could be different from lastthreadid if it's for a user in global ignore).
Reply With Quote
  #7  
Old 01-22-2013, 03:40 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Easy5s.net View Post
and use code
PHP Code:
"SELECT lastthreaddateline FROM " TABLE_PREFIX "thread WHERE threadid = " $forum['lastthreadid'
Unknown column 'lastthreaddateline' in 'field list'

Yeah, sorry, I deleted that because I'm now confused as to whether or not lastthreadid is the thread you want. In any case it should have been "SELECT dateline AS lastthreaddateline" (or just "SELECT dateline", but I was trying to make it consistent with the other pluigin code I posted).

Edit nvm, it looks like the lastthread information *is* the info for the last thread posted in, so (if I understood you correctly) it is what you want.
Reply With Quote
  #8  
Old 01-22-2013, 03:45 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have not seen any code works
Reply With Quote
  #9  
Old 01-22-2013, 03:49 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you try the cache_ordered_forums plugin with just this one line of code:
Code:
$counter_select .= ', thread.dateline AS lastthreaddateline ';

or try the query in your plugin using this:
Code:
"SELECT dateline AS lastthreaddateline FROM " . TABLE_PREFIX . "thread WHERE threadid = " . $forum['lastthreadid']

or are you saying you've tried those (without errors) but it's still not working?
Reply With Quote
  #10  
Old 01-22-2013, 04:03 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

edit....
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:44 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.04069 seconds
  • Memory Usage 2,264KB
  • 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
  • (6)bbcode_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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