Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 02-25-2009, 02:43 AM
Zero 3 Zero 3 is offline
 
Join Date: Sep 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Displaying Threads on my Website Index (Update)

Hi,

I just started a new website and switched over to vBulletin from phpBB. The last website I had, I was able to integrate forum posts within my site index. I used this code before: http://deceptive-logic.com/tutorial/php/topic with a little bit of tweaking. I want to do the same thing, but use vBulletin.

I forgot how to do a lot of coding, but I used to be decent with it (It's been 4 years since I last coded any time of script). If someone could please link me to a tutorial or be nice enough to place the required code I need, I would be very thankful. If you have any questions please PM me.

Thank you!
- Walter

--------------- Added [DATE]1235538702[/DATE] at [TIME]1235538702[/TIME] ---------------

Basically we want to integrate a particular forum/thread to show topics on our homepage. Our home page will be HTML.
Reply With Quote
  #2  
Old 02-25-2009, 05:47 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just include global.php, and run a query to fetch this data.
PHP Code:
$threads $vbulletin->db->query_read("
    SELECT *
    FROM " 
TABLE_PREFIX "thread
    WHERE forumid = X
    ORDER BY dateline DESC
    LIMIT 5
"
);

while (
$thread $vbulletin->db->fetch_array($threads))
{
    
// thread data is in $thread

Reply With Quote
  #3  
Old 02-25-2009, 06:06 AM
Zero 3 Zero 3 is offline
 
Join Date: Sep 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

can we get a little more clarification on this? How in fact do we run a query to fetch that data.

This is what we have so far:

Code:
LINE 50<?php include(Forum/global.php);
			$threads = $vbulletin->db->query_read("
    SELECT *
    FROM " . blakecul_vbullet . "thread
    WHERE forumid = 2
    ORDER BY dateline DESC
    LIMIT 5
");

while ($thread = $vbulletin->db->fetch_array($threads))
{
    // thread data is in $thread
}  ?>
And receiving: Parse error: syntax error, unexpected T_GLOBAL in /home/blakecul/public_html/layoutsliced.php on line 50
Reply With Quote
  #4  
Old 02-25-2009, 06:56 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You must use quotes, and include global.php like so: (This bit of code has been posted around a lot.)
PHP Code:
$curdir getcwd();
chdir('./forums');
require_once(
'./global.php');
chdir($curdir); 
Reply With Quote
  #5  
Old 02-25-2009, 02:18 PM
Zero 3 Zero 3 is offline
 
Join Date: Sep 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you! I think I'm a few steps short of getting it to work now since it's no longer stretching the tables and giving me errors. Now to get the threads to appear I assume I put something to display the threads here:

Code:
{
    // thread data is in $thread
}

This is the page in particular:

http://www.ydnfutc.com/layoutsliced.php

The big white content box on the right is where the threads would be appearing. What code do I use to display $thread
Reply With Quote
  #6  
Old 02-26-2009, 05:46 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As mentioned, all the thread's data is in an array in $thread. You need to process this data to whatever way you want.
Reply With Quote
  #7  
Old 02-26-2009, 04:21 PM
Zero 3 Zero 3 is offline
 
Join Date: Sep 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I did an array dump. I can't find the body of the post in that array (like the stuff I'm typing right now)

What I'm trying to do is go:

Quote:

"Title of thread here!" - By Walter

This is the body of the thread, the actual post itself.
What array do I need to get to gather the body of the post?
Reply With Quote
  #8  
Old 02-26-2009, 09:46 PM
Alessandro68 Alessandro68 is offline
 
Join Date: Feb 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I'm a newbie to php. How would you display the data in $thread in the following loop:

while ($thread = $vbulletin->db->fetch_array($threads))
{
// display data is in $thread
} ?>
Reply With Quote
  #9  
Old 02-27-2009, 01:10 AM
Zero 3 Zero 3 is offline
 
Join Date: Sep 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, I did something called a dump, which shows you all the data inside the array. You need to replace this:

Code:
while ($thread = $vbulletin->db->fetch_array($threads))
{
// display data is in $thread
}
With this:

Code:
while ($thread = $vbulletin->db->fetch_array($threads))
{
       echo "<pre>";var_dump($thread);die;
}
It's going to list a bunch of items. You need to copy that and save that information in a text document or something (to refer back to later).

For me, I needed to gather the Title of the thread and the persons name who posted the thread, so it was in the format

"Thread Title!" - By UsernameHere

The two variables for that are ['title'] and ['postusername']. Once you have the variables you need, You can gather them by using an echo function:

Code:
while ($thread = $vbulletin->db->fetch_array($threads))
{
       echo $thread['title']." - By ".$thread['postusername']."<br>";
}
Basically, using the echo function, then following it with the array $thread and the variable ['title'] will give you this:

Code:
{
echo $thread['title']
}
Hope that helps! I went to http://www.phpfreaks.com to get help on this matter. They were very friendly and responded very quickly.
Reply With Quote
  #10  
Old 02-27-2009, 07:03 AM
Alessandro68 Alessandro68 is offline
 
Join Date: Feb 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you veru much, appreciated !
Reply With Quote
Reply

Thread Tools
Display Modes

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 05:42 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08835 seconds
  • Memory Usage 2,248KB
  • 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
  • (6)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (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_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