View Full Version : Display Latest Thread Started by User in One Forum
H3C x Nevz
05-16-2009, 05:10 PM
I have a forum (ID 26 for explaining purposes), and I have already installed a blank extra tab in everyone's profile. What I would like to do is have the latest thread the user has posted in forumid26 to appear in that tab. (JUST the body content). How would I set up the variables for this?
Lynne
05-16-2009, 05:32 PM
Query for it.... something like (you'll have to play with it):
$myid=$this->profile->userinfo['userid'];
$getthreads = $vbulletin->db->query_first("
SELECT thread.threadid,thread.title,thread.dateline,threa d.forumid,thread.firstpostid, post.pagetext
FROM " . TABLE_PREFIX ."thread
LEFT JOIN " . TABLE_PREFIX ."post ON (post.postid=thread.firstpostid)
WHERE postuserid = '$myid' AND forumid=26 AND sticky=0
ORDER BY thread.dateline DESC
LIMIT 1
");
That should get you what you need and then do what you want with the results. I have NOT tested that query AT ALL. Play with this on a test site, not a live site.
H3C x Nevz
05-16-2009, 05:55 PM
I used that, and it gives me the following error:
Parse error: syntax error, unexpected T_STRING in D:\Inetpub\virtual\xmf53y55qg\WWWROOT\forum\member .php(462) : eval()'d code on line 31
Here's what I have for the plugin for adding an extra profile tab.
$blocklist = array_merge($blocklist, array(
'mymodification' => array(
'class' => 'MyModification',
'title' => 'Portfolio',
'hook_location' => 'profile_left_last'
)
));
class vB_ProfileBlock_MyModification extends vB_ProfileBlock
{
var $template_name = 'memberinfo_block_mymodification';
function confirm_empty_wrap()
{
return false;
}
function confirm_display()
{
return ($this->block_data['mymodification'] != '');
}
function prepare_output($id = '', $options = array())
{
$this->block_data['mymodification'] = '$myid=$this->profile->userinfo['userid'];
$getthreads = $vbulletin->db->query_first("
SELECT thread.threadid,thread.title,thread.dateline,threa d.forumid,thread.firstpostid, post.pagetext
FROM " . TABLE_PREFIX ."thread
LEFT JOIN " . TABLE_PREFIX ."post ON (post.postid=thread.firstpostid)
WHERE postuserid = '$myid' AND forumid=26 AND sticky=0
ORDER BY thread.dateline DESC
LIMIT 1
");';
}
}
Lynne
05-16-2009, 06:04 PM
Um... no. You need to do the query and all before you ever try to put anything into $this->block_data. You need to grab the info and get the variables defined before you ever try to spit it out as data (which is what $this->block_data is). Put it in the function, but before the block_data gets spit out. You are going to have to write the block_data stuff all yourself. I'm just giving you the query to get the information you need.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.