Current time: 04-23-2014, 02:38 PM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 2 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying News on Homepage
10-01-2005, 08:40 PM
Post: #21
RE: Displaying News on Homepage
Thanks agian, works great! *reps*

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
10-02-2005, 02:59 AM
Post: #22
RE: Displaying News on Homepage
Works beautifully! It would be even better if you got the BB codes working! Smile

@justinsoltesz - MyBB Lead Designer - jsoltesz.com - rctgo.com - quizli.com
Visit this user's website Find all posts by this user
Quote this message in a reply
10-02-2005, 12:56 PM (This post was last modified: 10-02-2005 02:33 PM by Lee69.)
Post: #23
RE: Displaying News on Homepage
Belloman Wrote:Works beautifully! It would be even better if you got the BB codes working! Smile

In order for BBCode to work, use this code below. Note, I haven't compared it between k776's and ours, so the layout may look different. Smile

PHP Code:
<?php 
$forumpath 
"./forums/"// Path to your forums root directory (with trailing slash)
$fid "15"// The forum ID to pull the annoucements from
$limit "7"// The amount of annoucements to show

require $forumpath."inc/config.php";function bb_code(&$string){
    
$pattern = array(
        
//[ul]
        
'#\[list\](.*?)\[\/list\]#si',
        
//[*]
        
'#\[\*\](.*?)(\r\n|\r|\n|<br>|<br />|<br/>)#si',
        
//[url]
        
'#\[url\](.*?)\[\/(url)\]#si',
        
//[url=XXX]
        
'#\[url=(&quot;|"|\'|)(.*?)\\1\](.*?)\[\/url\]#si',    
        
//[i],[u]
        
'#\[u\](.*?)\[/u\]#si',
        
'#\[i\](.*?)\[/i\]#si',
        
//[b]
        
'#\[b\](.*?)\[/b\]#si',
        
//[img]
        
'#\[img\](.*?)\[\/img\]#si',
        
// font size
        
'#\[size=(&quot;|"|\'|)([0-9\+\-]+)\\1\](.*?)\[\/size\]#si',        '#(\r|\n|\r\n)#si');

    
$replacement = array(
        
//ul
        
"\t\t<ul>$1</ul>\r\n",
        
//li
        
"\t\t\t<li>$1</li>\r\n",
        
//a
        
'<a href="$1">$1</a>',
        
//a
        
'<a href="$2">$3</a>',
        
//i, u
        
'<u>$1</u>',
        
'<em>$1</em>',
        
//b
        
'<strong>$1</strong>',
        
//img                            
        
'<img src="$1" alt="User Posted Image" />',
        
//size                
        
'<font size="\2">\3</font>',        "<br />");
    
$string preg_replace ($pattern$replacementstripslashes($string) );    $string str_replace ('<br /><br />'"</p>\r\n\t\t<p>"$string);
}
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("jS F Y"$news['dateline']);
    
$time gmdate("h:i A"$news['dateline']);    bb_code($news['message']);    if($news['replies'] == "1")
    {
        
$replytext "reply";
    }
    else
    {
        
$replytext "replies";
    }
    if(
$news['avatar'] != "")
    {
        if(
substr($news['avatar'], 07) != "http://")
        {
            
$url $forumpath;
        }
        
$avatarbit "<img style='float:left; margin:10px;'src=\"".$url.$news['avatar']."\" alt=\"".$url.$news['avatar']."\" />\r\n\t\t";
    }
    else
    {
        
$avatarbit "";
    }
    echo 
"\t<div class=\"news\">\r\n\t\t";
    echo 
"<div class='details'>(<a href=\"".$forumpath."showthread.php?tid=".$news['tid']."\">".$news['replies']." ".$replytext."</a>) | Posted by <a href=\"".$forumpath."member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a> on ".$date." at ".$time."(GMT+1)</div>\r\n\t\t";
    echo 
"<h2>".$news['subject']."</h2>\r\n\t\t";
    echo 
$avatarbit."<p>".$news['message']."</p>\r\n\t\t<div style=\"clear:both;\"></div>\r\n\t";
    echo 
"</div>\r\n";
}
?>

ApexDC++ - The Pinnacle of File-Sharing
Visit this user's website Find all posts by this user
Quote this message in a reply
10-02-2005, 01:03 PM
Post: #24
RE: Displaying News on Homepage
The bbcode parser from that was coded for vBulletin though, and it is buggy, especially around lists so if you want to use it then modify it for your needs.

Why doesn't MyBB totally transfer to CSS? like in this template (the divs and all) instead of having tables? That would, imo, make MyBB the best. Well, as far as templates go anyway Toungue
Find all posts by this user
Quote this message in a reply
10-02-2005, 01:14 PM
Post: #25
RE: Displaying News on Homepage
That one doesn't work for me. I just get:

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /hsphere/local/home/belloman/bellomanstudios.simgames.net/weee.php on line 68

@justinsoltesz - MyBB Lead Designer - jsoltesz.com - rctgo.com - quizli.com
Visit this user's website Find all posts by this user
Quote this message in a reply
10-02-2005, 01:27 PM (This post was last modified: 10-03-2005 09:02 AM by Xilon.)
Post: #26
RE: Displaying News on Homepage
That's because a smilie got in the way in that code :| weird... anyway try this:
PHP Code:
<?php 
require $forumpath."inc/config.php";

function 
bb_code(&$string){
    
$pattern = array(
        
//[ul]
        
'#\[list\](.*?)\[\/list\]#si',
        
//[*]
        
'#\[\*\](.*?)(\r\n|\r|\n|<br>|<br />|<br/>)#si',
        
//[url]
        
'#\[url\](.*?)\[\/(url)\]#si',
        
//[url=XXX]
        
'#\[url=(&quot;|"|\'|)(.*?)\\1\](.*?)\[\/url\]#si',       
        
//[i],[u]
        
'#\[u\](.*?)\[/u\]#si',
        
'#\[i\](.*?)\[/i\]#si',
        
//[b]
        
'#\[b\](.*?)\[/b\]#si',
        
//[img]
        
'#\[img\](.*?)\[\/img\]#si',
        
// font size
        
'#\[size=(&quot;|"|\'|)([0-9\+\-]+)\\1\](.*?)\[\/size\]#si',        '#(\r|\n|\r\n)#si');

    
$replacement = array(
        
//ul
        
"\t\t<ul>$1</ul>\r\n",
        
//li
        
"\t\t\t<li>$1</li>\r\n",
        
//a
        
'<a href="$1">$1</a>',
        
//a
        
'<a href="$2">$3</a>',
        
//i, u
        
'<u>$1</u>',
        
'<em>$1</em>',
        
//b
        
'<strong>$1</strong>',
        
//img                             
        
'<img src="$1" alt="User Posted Image" />',
        
//size                  
        
'<font size="\2">\3</font>',        "<br />");
    
$string preg_replace ($pattern$replacementstripslashes($string) );    $string str_replace ('<br /><br />'"</p>\r\n\t\t<p>"$string);
}
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 ("jS F Y"$news['dateline']);
    
$time gmdate ("h:i A"$news['dateline']);

    
//Parse BBCode
    
bb_code($news['message']);

    if(
$news['replies'] == "1"){
        
$replytext "reply";
    } else {
        
$replytext "replies";
    }

    if(
$news['avatar'] != ""){
        if(
substr($news['avatar'], 07) != "http://")
        {
            
$url $forumpath;
        }
        
$avatarbit "<img style='float:left; margin:10px;'src=\"".$url.$news['avatar']."\" alt=\"".$url.$news['avatar']."\" />\r\n\t\t";
    } else {
        
$avatarbit "";
    }

    echo 
"\t<div class=\"news\">\r\n\t\t";
    echo 
"<div class='details'>(<a href=\"".$forumpath."showthread.php?tid=".$news['tid']."\">".$news['replies']." ".$replytext." </a>) | Posted by <a href=\"".$forumpath."member.php?action=profile&amp;uid=".$news['uid']."\">".$news['username']."</a> on ".$date." at ".$time."</div>\r\n\t\t";
    echo 
"<h2>".$news['subject']."</h2>\r\n\t\t";
    echo 
$avatarbit."<p>".$news['message']."</p>\r\n\t\t<div style=\"clear:both;\"></div>\r\n\t";
    echo 
"</div>\r\n";
}
?>
Find all posts by this user
Quote this message in a reply
10-02-2005, 01:56 PM (This post was last modified: 10-02-2005 03:44 PM by Justin S..)
Post: #27
RE: Displaying News on Homepage
When I add this to the beginning, it works.

Quote:$forumpath = "./forums/"; // Path to your forums root directory (with trailing slash)
$fid = "4"; // The forum ID to pull the annoucements from
$limit = "10"; // The amount of annoucements to show

But above each post, I get this:

Warning: preg_replace(): Compilation failed: missing ) at offset 146 in /hsphere/local/home/belloman/bellomanstudios.simgames.net/weee.php on line 46

EDIT: Okay, now it works. There was a smilie in there for some reason...

Thanks for this!
- Belloman

2nd Edit: I have it up and running on my site! Yippee! Thanks for this. I really love it now! Smile

@justinsoltesz - MyBB Lead Designer - jsoltesz.com - rctgo.com - quizli.com
Visit this user's website Find all posts by this user
Quote this message in a reply
10-12-2005, 02:52 AM
Post: #28
RE: Displaying News on Homepage
Gah! I keep getting "No database selected" but I have all the correct credentials.
Find all posts by this user
Quote this message in a reply
10-12-2005, 08:23 PM
Post: #29
RE: Displaying News on Homepage
Anyway we can get a border on the code Xilon posted?

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
10-13-2005, 01:31 AM (This post was last modified: 10-13-2005 01:34 AM by k776.)
Post: #30
RE: Displaying News on Homepage
Hello. An update. I'm still working on this (not as fast as before). I got everything except badword filter and smilies working. Just need permission from Chris to release it now (since its redistributing a decompiled functions_post.php file).
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