PDA

View Full Version : Help me show


Easy5s.net
01-22-2013, 02:33 PM
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.

$thread['dateline'] = vbdate($vbulletin->options['op_date_format'], $lastpostinfo['lastpost']);
$lastpostinfo['trimthread'] = '['.$thread['dateline'].'] '.$lastpostinfo['trimthread'];

kh99
01-22-2013, 02:55 PM
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.

Easy5s.net
01-22-2013, 03:01 PM
You can guide me to select the table and should have what conditions? Please give me an example.

SELECT * what ?
WHERE ?

kh99
01-22-2013, 03:18 PM
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:
$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.

Easy5s.net
01-22-2013, 03:33 PM
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:
$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 :(

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
"SELECT lastthreaddateline FROM " . TABLE_PREFIX . "thread WHERE threadid = " . $forum['lastthreadid']

Unknown column 'lastthreaddateline' in 'field list'

kh99
01-22-2013, 03:38 PM
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).

kh99
01-22-2013, 03:40 PM
and use 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.

Easy5s.net
01-22-2013, 03:45 PM
I have not seen any code works :(

kh99
01-22-2013, 03:49 PM
Did you try the cache_ordered_forums plugin with just this one line of code:
$counter_select .= ', thread.dateline AS lastthreaddateline ';


or try the query in your plugin using this:
"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?

Easy5s.net
01-22-2013, 04:03 PM
edit....

kh99
01-22-2013, 04:08 PM
Assuming you have the new plugin working, you'd also have to change your code to use the new field. I think you just have to change the $thread['dateline'] line like this:

$thread['dateline'] = vbdate($vbulletin->options['op_datetime'], $lastpostinfo['lastthreaddateline']);

Easy5s.net
01-22-2013, 04:18 PM
Wrong place?
$test = $vbulletin->db->query_read("
SELECT dateline AS lastthreaddateline
FROM " . TABLE_PREFIX . "thread
WHERE threadid = " . $forum['lastthreadid'] . "
");

$thread['dateline'] = vbdate($vbulletin->options['op_datetime'], $test['lastthreaddateline']);
$lastpostinfo['trimthread'] = '['.$thread['dateline'].'] '.$lastpostinfo['trimthread'];

kh99
01-22-2013, 04:25 PM
You'd want to use query_first() instead of query_read() (or else you'd have to call fetch_array()).

Easy5s.net
01-22-2013, 04:37 PM
you can edit help me

kh99
01-22-2013, 04:41 PM
What you had above looked OK, just change the first line to:

$test = $vbulletin->db->query_first("

Easy5s.net
01-22-2013, 09:36 PM
No change, still display the last post time

kh99
01-22-2013, 09:57 PM
Hmm...well, I checked to make sure that the thread table dateline field is the date of the first post, so I can't see how that would happen. Maybe someone else will see the problem.