Current time: 02-04-2012, 02:43 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 5 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forum Integration - Recent Posts on Main Site
01-07-2010, 11:20 PM
Post: #1
Forum Integration - Recent Posts on Main Site
I'm not too savvy at php but using some resources from here and a bit of time I've got a great working version to integrate your main site with recent forum posts.

Although fully editable, this script will display:

Subject
Subject Creator
Replies
Views
Last Poster

a working example can be found here: http://www.backofthelandingnet.co.uk

Instructions:

1. Put this php script at the beginning of the page you want to display the recent posts on line 1 (before the HEAD tags)

Code:
<?php
chdir("pathtoforums/"); // path to MyBB
define("IN_MYBB", 1);
require("./global.php");
?>

2. edit the chdir to the path to your forum

3. Insert the code below where you want recent posts to be displayed

Code:
<?php

    $query = mysql_query("
            SELECT t.*, u.username
            FROM mybb_threads t
            LEFT JOIN mybb_users u ON (u.uid=t.uid)
            WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
            ORDER BY t.lastpost DESC
            LIMIT 0, 6" // Change the last digit to how many recent post you want to be shown
        );

    $list = '';
    while($fetch = mysql_fetch_array($query))
    {
        $list .= "<strong><a href=\"forums/showthread.php?tid={$fetch['tid']}\">".htmlspecialchars_uni($fetch['subject'])."</a></strong><br />";
        $poster = "<a href=\"forums/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
        $list .= "Created by: {$poster}<br />";
        $list .= "<i>" .$fetch['replies']. " Replies</i>";
        $list .= "<i> , " .$fetch['views']. " Views</i><br />";
        $list .= " (<i>Last post by: " .$fetch['lastposter']. "</i>)<br /><hr width=\"50\"><br />";
    
    }
    //output
    echo $list;

?>

4. Change the amount of recent posts you want to have displayed

That's it!
Find all posts by this user
Quote this message in a reply
01-07-2010, 11:30 PM
Post: #2
RE: Forum Integration - Recent Posts on Main Site
Looks Good. Let me have a try with this.

Thanks.

vBulletin/Wordpress/Magento/MyBB
Developer and Designer
Visit this user's website Find all posts by this user
Quote this message in a reply
01-08-2010, 02:00 PM
Post: #3
RE: Forum Integration - Recent Posts on Main Site
Awesome! Thanks a lot Smile
Find all posts by this user
Quote this message in a reply
02-05-2010, 07:28 PM (This post was last modified: 02-06-2010 04:36 PM by themulhaq.)
Post: #4
RE: Forum Integration - Recent Posts on Main Site
Im getting this error ... I dont know why

Warning: chdir() [function.chdir]: No such file or directory (errno 2) in /home/fpshar5/public_html/home.php on line 2

Warning: require(http://www.fpsharepoints.com/board/global.php) [function.require]: failed to open stream: No such file or directory in /home/fpshar5/public_html/home.php on line 4

Warning: require(http://www.fpsharepoints.com/board/global.php) [function.require]: failed to open stream: No such file or directory in /home/fpshar5/public_html/home.php on line 4

Fatal error: require() [function.require]: Failed opening required 'www.fpsharepoints.com/board/global.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fpshar5/public_html/home.php on line 4
anyone will answer of my above question?
Find all posts by this user
Quote this message in a reply
02-08-2010, 06:55 AM
Post: #5
RE: Forum Integration - Recent Posts on Main Site
My website have html pages, is there any way to add that code in those html ed pages ?
Find all posts by this user
Quote this message in a reply
02-08-2010, 09:19 AM
Post: #6
RE: Forum Integration - Recent Posts on Main Site
Change them to PHP pages (Just changing the extension is enough), then put that code in where wanted.
Find all posts by this user
Quote this message in a reply
02-08-2010, 11:11 PM
Post: #7
RE: Forum Integration - Recent Posts on Main Site
(02-05-2010 07:28 PM)themulhaq Wrote:  Im getting this error ... I dont know why

Warning: chdir() [function.chdir]: No such file or directory (errno 2) in /home/fpshar5/public_html/home.php on line 2

Warning: require(http://www.fpsharepoints.com/board/global.php) [function.require]: failed to open stream: No such file or directory in /home/fpshar5/public_html/home.php on line 4

Warning: require(http://www.fpsharepoints.com/board/global.php) [function.require]: failed to open stream: No such file or directory in /home/fpshar5/public_html/home.php on line 4

Fatal error: require() [function.require]: Failed opening required 'www.fpsharepoints.com/board/global.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fpshar5/public_html/home.php on line 4
anyone will answer of my above question?

Can you post the exact code you have used and also a link to your forums?
Find all posts by this user
Quote this message in a reply
02-10-2010, 09:39 AM (This post was last modified: 02-10-2010 09:39 AM by Cameron:D.)
Post: #8
RE: Forum Integration - Recent Posts on Main Site
When using the include function, you reference the file on the server, not the URL, so it would be
Code:
<?php
chdir("./board/"); // path to MyBB
define("IN_MYBB", 1);
require("./global.php");
?>
Assuming that your forum is in your public_html/board folder
Find all posts by this user
Quote this message in a reply
02-10-2010, 11:27 AM
Post: #9
RE: Forum Integration - Recent Posts on Main Site
Thanx this i was searching from many time. Good work.

You Too Can Earn Like Me
Find all posts by this user
Quote this message in a reply
02-10-2010, 10:48 PM (This post was last modified: 02-10-2010 10:53 PM by TStarGermany.)
Post: #10
RE: Forum Integration - Recent Posts on Main Site
if you have the mybb global.php integrated already,there's no need to form complicated sql commands for getting proper results

usually, a query like this is sufficient:
PHP Code:
$query $db->simple_select('threads''*'"fid='{$fid}' ORDER BY tid DESC 

--no ad, just info--
if you want, you can look at my news page (click), the script which catches+formats+outputs the news is just 4kb large (90% of it html/css formatting of the post content).
it's even more lightweight than Tikitiki's site news plugin).

[Image: 350x19.jpg][Image: tstargermany.png]
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication