Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-14-2010, 10:43 AM
just.b.jealous just.b.jealous is offline
 
Join Date: Aug 2009
Location: Middle of no where.
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default I need help making this plugin,..

I'd like to be able to display the (postdate/time, username, thread title, and post content) for the latest 5/10 threads from a specific forum/s?

Is there anyway to make a plug-in so I could put a variable where it's needed.

Similiar to this here (which only displays 10 latest post - showing only the thread title and username):

Code:
$numposts='10';


    $thrdqry = $vbulletin->db->query_read("
        SELECT forumid,threadid, title, dateline, lastpost, visible, open, lastposter      
        FROM " . TABLE_PREFIX . "thread
                WHERE forumid IN (1, 2, 3) AND visible = '1' 
        ORDER BY lastpost DESC
          LIMIT 0, $numposts ");

        while ($thrds = mysql_fetch_array($thrdqry))    
    {

    $ttid = $thrds[threadid]; 
        $pstqry = $vbulletin->db->query_read("
        SELECT postid      
        FROM " . TABLE_PREFIX . "post                        
                WHERE threadid= $ttid 
                ORDER BY postid DESC");

        $psts = mysql_fetch_array($pstqry);
        $pstid = $psts[postid];
            

$homepage_recentpost .=<<<EOD
$thrds[title]
$thrds[lastposter]
EOD;
            
    }
        $db->free_result($thrds);
                $db->free_result($psts);

the I just post $homepage_recentpost into a template and vB does the rest, some help would be greatly appreciated,..
Reply With Quote
  #2  
Old 12-15-2010, 05:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could do this:

PHP Code:
$numposts='10';


$thrdqry $vbulletin->db->query_read("
    SELECT thread.title, username, post.dateline, post.pagetext FROM " 
TABLE_PREFIX "thread AS thread
            LEFT JOIN " 
TABLE_PREFIX "post AS post ON thread.lastpostid = post.postid
            WHERE thread.forumid IN (1, 2, 3) AND thread.visible = '1'
    ORDER BY lastpost DESC
    LIMIT 0, 
$numposts ");

while (
$thrds $vbulletin->db->fetch_array($thrdqry))    
{
    
$postdate vbdate($vbulletin->options['dateformat'], $thrds['dateline'], true);
    
$posttime vbdate($vbulletin->options['timeformat'], $thrds['dateline']);

    
$homepage_recentpost .=<<<EOD
$thrds[title] $thrds[username] $postdate $posttime
<BR>
$thrds[pagetext]
<BR><BR>
EOD;
            


This doesn't check permissions of course, but maybe you're not worried about that.
A bigger problem is that this doesn't handle bbcode in the text.
Reply With Quote
  #3  
Old 12-15-2010, 11:40 PM
just.b.jealous just.b.jealous is offline
 
Join Date: Aug 2009
Location: Middle of no where.
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You could do this:

PHP Code:
$numposts='10';


$thrdqry $vbulletin->db->query_read("
    SELECT thread.title, username, post.dateline, post.pagetext FROM " 
TABLE_PREFIX "thread AS thread
            LEFT JOIN " 
TABLE_PREFIX "post AS post ON thread.lastpostid = post.postid
            WHERE thread.forumid IN (1, 2, 3) AND thread.visible = '1'
    ORDER BY lastpost DESC
    LIMIT 0, 
$numposts ");

while (
$thrds $vbulletin->db->fetch_array($thrdqry))    
{
    
$postdate vbdate($vbulletin->options['dateformat'], $thrds['dateline'], true);
    
$posttime vbdate($vbulletin->options['timeformat'], $thrds['dateline']);

    
$homepage_recentpost .=<<<EOD
$thrds[title] $thrds[username] $postdate $posttime
<BR>
$thrds[pagetext]
<BR><BR>
EOD;
            

This doesn't check permissions of course, but maybe you're not worried about that.
A bigger problem is that this doesn't handle bbcode in the text.
Thanks for helping me out, I'm not too good with plugins yet, template stuff is easy. 1 more question for ya, or anyone else who knows, I'm sure it would be pretty easy- any chance of making this just pick up the last thread posted/user/date/contents, instead of the last poster in a thread?

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

Quote:
Originally Posted by just.b.jealous View Post
I'm sure it would be pretty easy- any chance of making this just pick up the last thread posted/user/date/contents, instead of the last poster in a thread?
It does sound like it should be easy, but I'm afraid I don't understand what you want.
Reply With Quote
  #5  
Old 12-16-2010, 02:04 AM
just.b.jealous just.b.jealous is offline
 
Join Date: Aug 2009
Location: Middle of no where.
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
It does sound like it should be easy, but I'm afraid I don't understand what you want.
Oh sorry,. Right now the plugin displays:

When someone has posted in forums 1,2, or 3.
Displays the Username for who posted.
Displays the Title of the thread that they posted in.
Displays the Date & Time when they posted.

I would like it to display:
When someone has started a new thread (not a post) in forums 1,2, or 3.
Displays the Username for who started the thread (not the last poster).
Displays the Title of the new thread.
Displays the Date & Time when the new thread was posted.

Once again, thanks for helping me out.
Reply With Quote
  #6  
Old 12-16-2010, 02:42 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I think I see now. I think if you change lastpostid to firstpostid, and order by thread.dateline instead of lastpost that might do it. (There's a dateline in post as well, I don't know if the dateline of the first post is the same as the thread dateline or not. If not you might have to change post.dateline to thread.dateline on the SELECT line).

ETA: the answer seems to be that thread.dateline and dateline of the first post are sometimes different but I don't know why - maybe someone else does?
Reply With Quote
  #7  
Old 12-16-2010, 04:50 AM
just.b.jealous just.b.jealous is offline
 
Join Date: Aug 2009
Location: Middle of no where.
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome man, I can't appreciate it enough. I almost have it working- you might as well say it is. Last question, swear. Any way to pull the threads id into it as well? I'm trying to wrap the threads title with an href leading to the thread it's pulling, you'll see what I mean:

HTML Code:
$numposts='10';

$thrdqry = $vbulletin->db->query_read("
    SELECT thread.title, username, post.dateline, post.pagetext FROM " . TABLE_PREFIX . "thread AS thread
            LEFT JOIN " . TABLE_PREFIX . "post AS post ON thread.firstpostid = post.postid
            WHERE thread.forumid IN (61, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 130, 131, 132, 133, 134, 136, 137, 138, 139) AND thread.visible = '1'
    ORDER BY thread.dateline DESC
    LIMIT 0, $numposts ");

while ($thrds = $vbulletin->db->fetch_array($thrdqry))    
{
    $postdate = vbdate($vbulletin->options['dateformat'], $thrds['dateline'], true);
    $posttime = vbdate($vbulletin->options['timeformat'], $thrds['dateline']);
    $homepage_recentpost .=<<<EOD
<div class="post-1 post type-post hentry category-uncategorized" id="post-1">
	<h2 class="title"><a href="showthread.php?t=THREADID" target="_blank" alt="$thrds[title]" title="$thrds[title]">
		$thrds[title]
</a>
	</h2>
	<div class="postdate">
		<img src="images/date.png" /> $postdate <img src="images/user.png" /> $thrds[username] 
	</div>
	<div class="entry">
		<p>$thrds[pagetext]</p><br/><a href="showthread.php?t=THREADID" target="_blank" alt="$thrds[title]" title="$thrds[title]">
		Read more..
</a><br/>
	</div>
</div>
EOD;
            
}
Reply With Quote
  #8  
Old 12-16-2010, 07:14 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can add any field from the thread or post db tables just by adding it after SELECT. So if you add thread.threadid to the list of columns after SELECT you can use $thrds[threadid] to get your id.
Reply With Quote
  #9  
Old 12-17-2010, 02:36 AM
just.b.jealous just.b.jealous is offline
 
Join Date: Aug 2009
Location: Middle of no where.
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hell yeah, thanks a million bro, you made my life soo much easier..
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 02:28 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.06744 seconds
  • Memory Usage 2,272KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete