vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Display Latest Thread Started by User in One Forum (https://vborg.vbsupport.ru/showthread.php?t=213859)

H3C x Nevz 05-16-2009 05:10 PM

Display Latest Thread Started by User in One Forum
 
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):
PHP Code:

   $myid=$this->profile->userinfo['userid']; 
$getthreads $vbulletin->db->query_first(
                SELECT thread.threadid,thread.title,thread.dateline,thread.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:

Code:

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.

Code:

$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,thread.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.


All times are GMT. The time now is 01:03 AM.

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.00933 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete