Current time: 04-17-2014, 06:40 PM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 2 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying News on Homepage
09-26-2005, 07:54 PM
Post: #11
RE: Displaying News on Homepage
Still not working, I'll just use the portal it came with , thanks for the help.

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2005, 08:26 PM
Post: #12
RE: Displaying News on Homepage
Right. Finally got it working via MSN. Here is the final code
PHP Code:
<?php
$mysqlhost 
"localhost";
$mysqlusername "";
$mysqlpassword "";
$mysqldbselect "";
$prefix "mybb_";
$fid "2";

mysql_select_db($mysqldbselectmysql_connect($mysqlhost,$mysqlusername,$mysqlpassword));

$query mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.replies,p.message FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%'") or die(mysql_error());
while(
$news mysql_fetch_array($query))
{
echo 
"<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> | Posted by: <a href=\"./forum/member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>
Visit this user's website Find all posts by this user
Quote this message in a reply
09-27-2005, 12:19 AM (This post was last modified: 09-28-2005 07:25 AM by RandomNumber.)
Post: #13
RE: Displaying News on Homepage
Works beautifuly. Hmm wish there was a way to parse the bbcodes tho.

NetAdmin @ PharosIRC
irc.pharosirc.net
#Help,#lobby,#linux
MrStatic
Visit this user's website Find all posts by this user
Quote this message in a reply
09-28-2005, 04:55 PM (This post was last modified: 09-28-2005 05:16 PM by MereCatfish.)
Post: #14
RE: Displaying News on Homepage
Works, many thanks! Smile

By the way, it also displays comments as an actual news post, I am going to see if I can fix that.
Suprisingly simple, just add...

Code:
WHERE p.replyto='0'

in the query. Then you only get the first post of each thread.
Find all posts by this user
Quote this message in a reply
09-28-2005, 06:27 PM
Post: #15
RE: Displaying News on Homepage
great idea
Find all posts by this user
Quote this message in a reply
09-29-2005, 05:48 AM
Post: #16
RE: Displaying News on Homepage
What about adding an avatar and such?
Visit this user's website Find all posts by this user
Quote this message in a reply
10-01-2005, 02:52 AM (This post was last modified: 10-01-2005 06:58 AM by k776.)
Post: #17
RE: Displaying News on Homepage
Right. Because of the requests and a few bugs found, here is the new code. It now has a forum path value, which means it can now use MyBB's config file and correct all link/image paths itself instead of having to edit multiple details yourself. You can also now limit how many to show (default is 10), it should also order the posts to show the latest ones (not random ones) and only show the starting posts, not replies. It also displays the poster's avatar and the time the thread was made in a new outputting style.
PHP Code:
<?php
$forumpath 
"./MyBBForum/"// Path to your forums root directory (with trailing slash)
$fid "2"// The forum ID to pull the annoucements from
$limit "10"// The amount of annoucements to show

require $forumpath."inc/config.php";
mysql_select_db($config['database'], mysql_connect($config['hostname'], $config['username'], $config['password']));

$query mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.dateline,t.replies,p.message,u.avatar FROM ".$config['table_prefix']."threads t LEFT JOIN ".$config['table_prefix']."posts p ON (t.tid = p.tid) LEFT JOIN ".$config['table_prefix']."users u ON (t.uid = u.uid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND p.replyto='0' ORDER BY t.tid DESC LIMIT 0, ".$limit."") or die(mysql_error());
while(
$news mysql_fetch_array($query))
{
    
$date gmdate("d-m-Y"$news['dateline']);
    
$time gmdate("h:i A"$news['dateline']);
    if(
$news['replies'] == "1")
    {
        
$replytext "reply";
    }
    else
    {
        
$replytext "replies";
    }
    if(
$news['avatar'] != "")
    {
        if(
substr($news['avatar'], 07) != "http://")
        {
            
$url $forumpath;
        }
        
$avatarbit "<td valign=\"top\" style=\"border: solid 1px #000000;\" rowspan=\"2\" width=\"150\" align=\"center\"><img src=\"".$url.$news['avatar']."\" alt=\"".$url.$news['avatar']."\" /></td>";
    }
    else
    {
        
$avatarbit "";
    }
    echo 
"<table cellpadding=\"7\" align=\"center\" style=\"border: solid 0px #000000;\" width=\"100%\">\n";
    echo 
"<tr>".$avatarbit."<td style=\"border: solid 1px #000000;\"\"><a href=\"".$forumpath."showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> ( ".$news['replies']." ".$replytext." ) <br />Posted by <a href=\"".$forumpath."member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a> on ".$date." at ".$time."</td></tr>\n";
    echo 
"<tr><td style=\"border: solid 1px #000000;\"\">".$news['message']."</td></tr>\n";
    echo 
"</table><br />\n\n";
}
?>
I'm also in the middle of implementing BBcodes.
Visit this user's website Find all posts by this user
Quote this message in a reply
10-01-2005, 09:45 AM
Post: #18
RE: Displaying News on Homepage
k776 Wrote:Right. Because of the requests and a few bugs found, here is the new code. It now has a forum path value, which means it can now use MyBB's config file and correct all link/image paths itself instead of having to edit multiple details yourself. You can also now limit how many to show (default is 10), it should also order the posts to show the latest ones (not random ones) and only show the starting posts, not replies. It also displays the poster's avatar and the time the thread was made in a new outputting style.
PHP Code:
<?php
$forumpath 
"./MyBBForum/"// Path to your forums root directory (with trailing slash)
$fid "2"// The forum ID to pull the annoucements from
$limit "10"// The amount of annoucements to show

require $forumpath."inc/config.php";
mysql_select_db($config['database'], mysql_connect($config['hostname'], $config['username'], $config['password']));

$query mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.dateline,t.replies,p.message,u.avatar FROM ".$config['table_prefix']."threads t LEFT JOIN ".$config['table_prefix']."posts p ON (t.tid = p.tid) LEFT JOIN ".$config['table_prefix']."users u ON (t.uid = u.uid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND p.replyto='0' ORDER BY t.tid DESC LIMIT 0, ".$limit."") or die(mysql_error());
while(
$news mysql_fetch_array($query))
{
    
$date gmdate("d-m-Y"$news['dateline']);
    
$time gmdate("h:i A"$news['dateline']);
    if(
$news['replies'] == "1")
    {
        
$replytext "reply";
    }
    else
    {
        
$replytext "replies";
    }
    if(
$news['avatar'] != "")
    {
        if(
substr($news['avatar'], 07) != "http://")
        {
            
$url $forumpath;
        }
        
$avatarbit "<td valign=\"top\" style=\"border: solid 1px #000000;\" rowspan=\"2\" width=\"150\" align=\"center\"><img src=\"".$url.$news['avatar']."\" alt=\"".$url.$news['avatar']."\" /></td>";
    }
    else
    {
        
$avatarbit "";
    }
    echo 
"<table cellpadding=\"7\" align=\"center\" style=\"border: solid 0px #000000;\" width=\"100%\">\n";
    echo 
"<tr>".$avatarbit."<td style=\"border: solid 1px #000000;\"\"><a href=\"".$forumpath."showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> ( ".$news['replies']." ".$replytext." ) <br />Posted by <a href=\"".$forumpath."member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a> on ".$date." at ".$time."</td></tr>\n";
    echo 
"<tr><td style=\"border: solid 1px #000000;\"\">".$news['message']."</td></tr>\n";
    echo 
"</table><br />\n\n";
}
?>
I'm also in the middle of implementing BBcodes.

That is excellent. Thank's for your time. Sorry to annoy you via PM. Wink
Ok, we've modified your code to produce this:

http://dc.peerweb.org/ Big Grin

BBcode works. Haven't tried with the emoticons though.

ApexDC++ - The Pinnacle of File-Sharing
Visit this user's website Find all posts by this user
Quote this message in a reply
10-01-2005, 03:41 PM
Post: #19
RE: Displaying News on Homepage
Mind post or Pmin me that code...thats would rock. Big Grin

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
10-01-2005, 08:24 PM (This post was last modified: 10-01-2005 08:27 PM by k776.)
Post: #20
RE: Displaying News on Homepage
Lee™, very nice theme you have. So nice, I've changed the theme for this code to look like it (using MyBB's images though). More professional IMO :D You dont mind do you? Chadwick, use this code. I fixed a time bug, and made it use the style of Lee's site :D
PHP Code:
<?php
$forumpath 
"./forum/"// Path to your forums root directory (with trailing slash)
$fid "2"// The forum ID to pull the annoucements from
$limit "10"// The amount of annoucements to show

require $forumpath."inc/config.php";
mysql_select_db($config['database'], mysql_connect($config['hostname'], $config['username'], $config['password']));

$query mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.dateline,t.replies,p.message,u.avatar FROM ".$config['table_prefix']."threads t LEFT JOIN ".$config['table_prefix']."posts p ON (t.tid = p.tid) LEFT JOIN ".$config['table_prefix']."users u ON (t.uid = u.uid) WHERE t.fid='".$fid."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND p.replyto='0' ORDER BY t.tid DESC LIMIT 0, ".$limit."") or die(mysql_error());
while(
$news mysql_fetch_array($query))
{
    
$date date("jS of F Y"$news['dateline']);
    
$time date("h:i A"$news['dateline']);
    if(
$news['replies'] == "1")
    {
        
$replytext "reply";
    }
    else
    {
        
$replytext "replies";
    }
    if(
$news['avatar'] != "")
    {
        if(
substr($news['avatar'], 07) != "http://")
        {
            
$url $forumpath;
        }
        
$avatarbit "<img src=\"".$url.$news['avatar']."\" alt=\"".$url.$news['avatar']."\" style=\"float:left; margin: 5px;\" />";
    }
    else
    {
        
$avatarbit "";
    }
    echo 
"<table width=\"90%\" align=\"center\" bgcolor=\"black\" cellpadding=\"0\" cellspacing=\"1\">\n";
    echo 
"<tr><td bgcolor=\"white\" style=\"padding: 3px; background-image:url(".$forumpath."images/thead_bg.gif); font-weight: bold; font-family: Verdana; font-size: 13px;\"><span style=\"float:right; font-size: 9px;\">(<a href=\"".$forumpath."showthread.php?tid=".$news['tid']."\"><font color=\"white\">".$news['replies']." ".$replytext."</font></a>) | Posted by <a href=\"".$forumpath."member.php?action=profile&amp;uid=".$news['uid']."\"><font color=\"white\">".$news['username']."</font></a> on the ".$date." at ".$time."&nbsp;</span>&nbsp;".$news['subject']."</td></tr>\n";
    echo 
"<tr><td bgcolor=\"white\" style=\"padding: 5px;\">".$avatarbit.$news['message']."</td></tr>\n";
    echo 
"</table><br />\n\n";
}
?>
Visit this user's website 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