News Question
On some sites, they have forums with a news section. The news section updates to the main page of the site, at least I think that is how it works. They post on forum in news and then it shows up on main page? How do you do that? Or I am completely wrong here?
Example:
studioMMO.com has a News section in the forums. They have posts that are sticked as "LINKED" and they appear on the main page of the site.
--Sabby
ROzbeans
19 years ago
That's a phpbbnuke portal dealio. You might want to check with your webhost if they offer an installatron type deal like Deez does and you can install one lickety split. Or drop Jenna a pm about it. It is pretty fancy, vb doesn't offer it, at least not as a default, but maybe as an add on. I'll have to ask Vex now.
Vex
19 years ago
actually you can do that without phpnuke ( YUCK )
but your forum has to be on the same server as your website, or at least allow remote connections to the mysql server ( highly unlikely )
but your forum has to be on the same server as your website, or at least allow remote connections to the mysql server ( highly unlikely )
Vex
19 years ago
here is a code snippet that supports BBCode. you will need to make sure your forum's host allows remote connections, and double check the table names.
[php]
$conn = mysql_connect("MYSQLSERVER","USERNAME","PASSWORD") or die("cannot connect to server: ".mysql_error());
mysql_select_db("FORUMDATABASE") or die("cannot select db: ".mysql_error());
function parseBBCode($text){
$tagArray['img'] = array('open'=>'
');
$tagArray['b'] = array('open'=>'','close'=>'');
$tagArray['i'] = array('open'=>'','close'=>'');
$tagArray['u'] = array('open'=>'','close'=>'');
$tagArray['email'] = array('open'=>'\\1');
$tagArray['url=(.*)'] = array('open'=>'\\2');
$tagArray['url'] = array('open'=>'\\1');
$tagArray['email=(.*)'] = array('open'=>'\\2');
$tagArray['color=(.*)'] = array('open'=>'\\2');
$tagArray['size=(.*)'] = array('open'=>'\\2');
$tagArray['font=(.*)'] = array('open'=>'\\2');
$tagArray['quote'] = array('open'=>'
$tagArray['code'] = array('open'=>'
$sTagArray['\*'] = array('tag'=>'');
foreach($tagArray as $tagName=>$replace){
$tagEnd=preg_replace('/\W/Ui','',$tagName);
$text = preg_replace("|\[$tagName\](.*)\[/$tagEnd\]|Ui","$replace[open]\\1$replace[close]",$text);
}
foreach($sTagArray as $tagName=>$replace){
$text= preg_replace("|\[$tagName\]|Ui","$replace[tag]",$text);
}
$text = str_replace("
$text = nl2br($text);
return $text;
}
$getnewsposts = "SELECT topic_poster,topic_time,topic_first_post_id FROM phpbb_topics WHERE forum_id='7'";
$postsquery = mysql_query($getnewsposts) or die(mysql_error());
while ($posts = mysql_fetch_array($postsquery)) {
$topic_id = $posts['topic_first_post_id'];
$topic_poster = $posts['topic_poster'];
$topic_time = date("m/d/y g:i a",$posts['topic_time']);
$getposter = mysql_query("SELECT username FROM phpbb_users WHERE user_id='$topic_poster'");
$poster = mysql_result($getposter, 0);
$getposttext = "SELECT bbcode_uid,post_subject,post_text FROM phpbb_posts_text WHERE post_id='$topic_id'";
$postquery = mysql_query($getposttext) or die(mysql_error());
$post = mysql_fetch_array($postquery) or die(mysql_error());
$post_subject = $post['post_subject'];
$bbcode_uid = $post['bbcode_uid'];
$text = $post['post_text'];
$text = str_replace(":".$bbcode_uid,"",$text);
$text = str_replace(":u","",$text);
$text = parseBBCode($text);
?>
poster: = $poster; ?>
subject: = $post_subject; ?>
time: = $topic_time; ?>
full post: = $text; ?>
}
?>
[/php]you'd copy and paste the above block into a .php file ( ie: news.php ) ... the very last bit from poster to fullpost is where you format your posts.
[php]
$conn = mysql_connect("MYSQLSERVER","USERNAME","PASSWORD") or die("cannot connect to server: ".mysql_error());
mysql_select_db("FORUMDATABASE") or die("cannot select db: ".mysql_error());
function parseBBCode($text){
$tagArray['img'] = array('open'=>'
$tagArray['b'] = array('open'=>'','close'=>'');
$tagArray['i'] = array('open'=>'','close'=>'');
$tagArray['u'] = array('open'=>'','close'=>'');
$tagArray['email'] = array('open'=>'\\1');
$tagArray['url=(.*)'] = array('open'=>'\\2');
$tagArray['url'] = array('open'=>'\\1');
$tagArray['email=(.*)'] = array('open'=>'\\2');
$tagArray['color=(.*)'] = array('open'=>'\\2');
$tagArray['size=(.*)'] = array('open'=>'\\2');
$tagArray['font=(.*)'] = array('open'=>'\\2');
$tagArray['quote'] = array('open'=>'
','close'=>'
'); $tagArray['code'] = array('open'=>'
','close'=>'
'); $sTagArray['\*'] = array('tag'=>'
foreach($tagArray as $tagName=>$replace){
$tagEnd=preg_replace('/\W/Ui','',$tagName);
$text = preg_replace("|\[$tagName\](.*)\[/$tagEnd\]|Ui","$replace[open]\\1$replace[close]",$text);
}
foreach($sTagArray as $tagName=>$replace){
$text= preg_replace("|\[$tagName\]|Ui","$replace[tag]",$text);
}
$text = str_replace("
- ","
- ",$text);
$text = str_replace("
$text = nl2br($text);
return $text;
}
$getnewsposts = "SELECT topic_poster,topic_time,topic_first_post_id FROM phpbb_topics WHERE forum_id='7'";
$postsquery = mysql_query($getnewsposts) or die(mysql_error());
while ($posts = mysql_fetch_array($postsquery)) {
$topic_id = $posts['topic_first_post_id'];
$topic_poster = $posts['topic_poster'];
$topic_time = date("m/d/y g:i a",$posts['topic_time']);
$getposter = mysql_query("SELECT username FROM phpbb_users WHERE user_id='$topic_poster'");
$poster = mysql_result($getposter, 0);
$getposttext = "SELECT bbcode_uid,post_subject,post_text FROM phpbb_posts_text WHERE post_id='$topic_id'";
$postquery = mysql_query($getposttext) or die(mysql_error());
$post = mysql_fetch_array($postquery) or die(mysql_error());
$post_subject = $post['post_subject'];
$bbcode_uid = $post['bbcode_uid'];
$text = $post['post_text'];
$text = str_replace(":".$bbcode_uid,"",$text);
$text = str_replace(":u","",$text);
$text = parseBBCode($text);
?>
poster: = $poster; ?>
subject: = $post_subject; ?>
time: = $topic_time; ?>
full post: = $text; ?>
}
?>
[/php]you'd copy and paste the above block into a .php file ( ie: news.php ) ... the very last bit from poster to fullpost is where you format your posts.
Sabby
19 years ago
Awesome! =)
Sabby
19 years ago
My boyfriend was doing the coding for me on this, he's sleeping now, but asked me to ask here:
The page is eqsigs.com/news.php (I think...)
--Sabby
There is one isssue however, which I would appericate if you could bring up to Vex (maybe). The BBcode Parser doesn't correctly change BBcode links to HTML links, so any links we create in the forums do not show properly in the news.php page.
I would appericate it if she could take a look at it and see whats up.
The page is eqsigs.com/news.php (I think...)
--Sabby
Vex
19 years ago
Ok one sec and let me revise ;)
Vex
19 years ago
take a look here : http://www.vexiphne.net/newstest.php
^ thats essentially the exact same code i already gave you *scratches head*
[php]
$conn = mysql_connect("MYSQLSERVER","USERNAME","PASSWORD") or die("cannot connect to server: ".mysql_error());
mysql_select_db("FORUMDATABASE") or die("cannot select db: ".mysql_error());
function parseBBCode($text){
$tagArray['img'] = array('open'=>'
');
$tagArray['b'] = array('open'=>'','close'=>'');
$tagArray['i'] = array('open'=>'','close'=>'');
$tagArray['u'] = array('open'=>'','close'=>'');
$tagArray['email'] = array('open'=>'\\1');
$tagArray['url=(.*)'] = array('open'=>'\\2');
$tagArray['url'] = array('open'=>'\\1');
$tagArray['email=(.*)'] = array('open'=>'\\2');
$tagArray['color=(.*)'] = array('open'=>'\\2');
$tagArray['size=(.*)'] = array('open'=>'\\2');
$tagArray['font=(.*)'] = array('open'=>'\\2');
$tagArray['quote'] = array('open'=>'
$tagArray['code'] = array('open'=>'
$sTagArray['\*'] = array('tag'=>'');
foreach($tagArray as $tagName=>$replace){
$tagEnd=preg_replace('/\W/Ui','',$tagName);
$text = preg_replace("|\[$tagName\](.*)\[/$tagEnd\]|Ui","$replace[open]\\1$replace[close]",$text);
}
foreach($sTagArray as $tagName=>$replace){
$text= preg_replace("|\[$tagName\]|Ui","$replace[tag]",$text);
}
$text = str_replace("
$text = nl2br($text);
return $text;
}
$getnewsposts = "SELECT topic_poster,topic_time,topic_first_post_id FROM phpbb_topics WHERE forum_id='7'";
$postsquery = mysql_query($getnewsposts) or die(mysql_error());
while ($posts = mysql_fetch_array($postsquery)) {
$topic_id = $posts['topic_first_post_id'];
$topic_poster = $posts['topic_poster'];
$topic_time = date("m/d/y g:i a",$posts['topic_time']);
$getposter = mysql_query("SELECT username FROM phpbb_users WHERE user_id='$topic_poster'");
$poster = mysql_result($getposter, 0);
$getposttext = "SELECT bbcode_uid,post_subject,post_text FROM phpbb_posts_text WHERE post_id='$topic_id'";
$postquery = mysql_query($getposttext) or die(mysql_error());
$post = mysql_fetch_array($postquery) or die(mysql_error());
$post_subject = $post['post_subject'];
$bbcode_uid = $post['bbcode_uid'];
$text = $post['post_text'];
$text = str_replace(":".$bbcode_uid,"",$text);
$text = str_replace(":u","",$text);
$text = parseBBCode($text);
?>
poster: = $poster; ?>
subject: = $post_subject; ?>
time: = $topic_time; ?>
full post: = $text; ?>
}
?>
[/php]
^ thats essentially the exact same code i already gave you *scratches head*
[php]
$conn = mysql_connect("MYSQLSERVER","USERNAME","PASSWORD") or die("cannot connect to server: ".mysql_error());
mysql_select_db("FORUMDATABASE") or die("cannot select db: ".mysql_error());
function parseBBCode($text){
$tagArray['img'] = array('open'=>'
$tagArray['b'] = array('open'=>'','close'=>'');
$tagArray['i'] = array('open'=>'','close'=>'');
$tagArray['u'] = array('open'=>'','close'=>'');
$tagArray['email'] = array('open'=>'\\1');
$tagArray['url=(.*)'] = array('open'=>'\\2');
$tagArray['url'] = array('open'=>'\\1');
$tagArray['email=(.*)'] = array('open'=>'\\2');
$tagArray['color=(.*)'] = array('open'=>'\\2');
$tagArray['size=(.*)'] = array('open'=>'\\2');
$tagArray['font=(.*)'] = array('open'=>'\\2');
$tagArray['quote'] = array('open'=>'
','close'=>'
'); $tagArray['code'] = array('open'=>'
','close'=>'
'); $sTagArray['\*'] = array('tag'=>'
foreach($tagArray as $tagName=>$replace){
$tagEnd=preg_replace('/\W/Ui','',$tagName);
$text = preg_replace("|\[$tagName\](.*)\[/$tagEnd\]|Ui","$replace[open]\\1$replace[close]",$text);
}
foreach($sTagArray as $tagName=>$replace){
$text= preg_replace("|\[$tagName\]|Ui","$replace[tag]",$text);
}
$text = str_replace("
- ","
- ",$text);
$text = str_replace("
$text = nl2br($text);
return $text;
}
$getnewsposts = "SELECT topic_poster,topic_time,topic_first_post_id FROM phpbb_topics WHERE forum_id='7'";
$postsquery = mysql_query($getnewsposts) or die(mysql_error());
while ($posts = mysql_fetch_array($postsquery)) {
$topic_id = $posts['topic_first_post_id'];
$topic_poster = $posts['topic_poster'];
$topic_time = date("m/d/y g:i a",$posts['topic_time']);
$getposter = mysql_query("SELECT username FROM phpbb_users WHERE user_id='$topic_poster'");
$poster = mysql_result($getposter, 0);
$getposttext = "SELECT bbcode_uid,post_subject,post_text FROM phpbb_posts_text WHERE post_id='$topic_id'";
$postquery = mysql_query($getposttext) or die(mysql_error());
$post = mysql_fetch_array($postquery) or die(mysql_error());
$post_subject = $post['post_subject'];
$bbcode_uid = $post['bbcode_uid'];
$text = $post['post_text'];
$text = str_replace(":".$bbcode_uid,"",$text);
$text = str_replace(":u","",$text);
$text = parseBBCode($text);
?>
poster: = $poster; ?>
subject: = $post_subject; ?>
time: = $topic_time; ?>
full post: = $text; ?>
}
?>
[/php]
Sabby
19 years ago
Maybe he jumbled it? =P I blame Cory!! Thank you again, Vex.
Vex
19 years ago
not REALLY sure without seeing the code as it is on the server.
Sabby
19 years ago
How the hell do I link that like you did? When I quote it.. it comes out all fucked up.
ROzbeans
19 years ago
use [code ] [/code ] without the spaces.
Sabby
19 years ago
Erm, its jumbling...
[php]
$conn = mysql_connect("","","") or die("cannot connect to server: ".mysql_error());
mysql_select_db("eqsigs") or die("cannot select db: ".mysql_error());
function bb2html($text)
{
$bbcode = array(
'<',
'>',
'
'
',
'', '',
'', '',
'', '',
'',
'[color=(.*?)]',
'',
'',
'[size=(.*?)]',
' ',
'[url="(.*?)"]',
'[url=(.*?)]',
'',
'',
'[mail="(.*?)"]',
'[mail=(.*?)]',
'[/mail]',
'
'',
'\']'
);
$htmlcode = array(
'<', '>',
'
'
',
'', '',
'', '',
'', '',
'', '', '',
'', '', '', '',
'', '', '',
'
'', '',
'>');
$newtext = eregi_replace($bbcode, $htmlcode, $newtext);
$resize = "onmouseout=\"unpointercursor();\" onmouseover=\"if(this.width == 550) {pointercursor();}\" onclick=\"if(this.width == 550) { window.open('templates/subSilver/resizefix.php?originalsize={URL}', '_blank' ,'scrollbars=1,toolbar=no,resizable=1,menubar=no,directories=no,status=yes'); return false; }";
$newtext = str_replace("/
$newtext = nl2br($newtext);
return $newtext;
}
function parseBBCode($text){
$tagArray['img'] = array('open'=>'
');
$tagArray['b'] = array('open'=>'','close'=>'');
$tagArray['i'] = array('open'=>'','close'=>'');
$tagArray['u'] = array('open'=>'','close'=>'');
$tagArray['email'] = array('open'=>'\\1');
$tagArray['url=(.*)'] = array('open'=>'\\2');
$tagArray['url'] = array('open'=>'\\1');
$tagArray['email=(.*)'] = array('open'=>'\\2');
$tagArray['color=(.*)'] = array('open'=>'\\2');
$tagArray['size=(.*)'] = array('open'=>'\\2');
$tagArray['font=(.*)'] = array('open'=>'\\2');
$tagArray['quote'] = array('open'=>'
$tagArray['code'] = array('open'=>'
$sTagArray['\*'] = array('tag'=>'');
foreach($tagArray as $tagName=>$replace){
$tagEnd=preg_replace('/\W/Ui','',$tagName);
$text = preg_replace("|\[$tagName\](.*)\[/$tagEnd\]|Ui","$replace[open]\\1$replace[close]",$text);
}
foreach($sTagArray as $tagName=>$replace){
$text= preg_replace("|\[$tagName\]|Ui","$replace[tag]",$text);
}
$text = str_replace("
$text = nl2br($text);
return $text;
}
$getnewsposts = "SELECT topic_poster,topic_time,topic_first_post_id FROM phpbb_topics WHERE forum_id='7'ORDER BY `topic_id` DESC" ;
$postsquery = mysql_query($getnewsposts) or die(mysql_error());
while ($posts = mysql_fetch_array($postsquery)) {
$topic_id = $posts['topic_first_post_id'];
$topic_poster = $posts['topic_poster'];
$topic_time = date("m/d/y g:i a",$posts['topic_time']);
$getposter = mysql_query("SELECT username FROM phpbb_users WHERE user_id='$topic_poster'");
$poster = mysql_result($getposter, 0);
$getposttext = "SELECT bbcode_uid,post_subject,post_text FROM phpbb_posts_text WHERE post_id='$topic_id'";
$postquery = mysql_query($getposttext) or die(mysql_error());
$post = mysql_fetch_array($postquery) or die(mysql_error());
$post_subject = $post['post_subject'];
$bbcode_uid = $post['bbcode_uid'];
$text = $post['post_text'];
$text = str_replace(":".$bbcode_uid,"",$text);
$text = str_replace(":u","",$text);
$text = parseBBCode($text);
?>
= $post_subject; ?>
[php]
$conn = mysql_connect("","","") or die("cannot connect to server: ".mysql_error());
mysql_select_db("eqsigs") or die("cannot select db: ".mysql_error());
function bb2html($text)
{
$bbcode = array(
'<',
'>',
'
- ',
- ',
'
'
'
'', '',
'', '',
'', '',
'',
'[color=(.*?)]',
'',
'
'[size=(.*?)]',
'
'[url="(.*?)"]',
'[url=(.*?)]',
'',
'',
'[mail="(.*?)"]',
'[mail=(.*?)]',
'[/mail]',
'
',
'','
',
'
'\']'
);
$htmlcode = array(
'<', '>',
'
- ', '
- ', '
'
'', '',
'', '',
'', '',
'', '', '',
'', '', '', '',
'', '', '',
'
', '', '', '',
'>');
$newtext = eregi_replace($bbcode, $htmlcode, $newtext);
$resize = "onmouseout=\"unpointercursor();\" onmouseover=\"if(this.width == 550) {pointercursor();}\" onclick=\"if(this.width == 550) { window.open('templates/subSilver/resizefix.php?originalsize={URL}', '_blank' ,'scrollbars=1,toolbar=no,resizable=1,menubar=no,directories=no,status=yes'); return false; }";
$newtext = str_replace("/
$newtext = nl2br($newtext);
return $newtext;
}
function parseBBCode($text){
$tagArray['img'] = array('open'=>'
$tagArray['b'] = array('open'=>'','close'=>'');
$tagArray['i'] = array('open'=>'','close'=>'');
$tagArray['u'] = array('open'=>'','close'=>'');
$tagArray['email'] = array('open'=>'\\1');
$tagArray['url=(.*)'] = array('open'=>'\\2');
$tagArray['url'] = array('open'=>'\\1');
$tagArray['email=(.*)'] = array('open'=>'\\2');
$tagArray['color=(.*)'] = array('open'=>'\\2');
$tagArray['size=(.*)'] = array('open'=>'\\2');
$tagArray['font=(.*)'] = array('open'=>'\\2');
$tagArray['quote'] = array('open'=>'
','close'=>'
'); $tagArray['code'] = array('open'=>'
','close'=>'
'); $sTagArray['\*'] = array('tag'=>'
foreach($tagArray as $tagName=>$replace){
$tagEnd=preg_replace('/\W/Ui','',$tagName);
$text = preg_replace("|\[$tagName\](.*)\[/$tagEnd\]|Ui","$replace[open]\\1$replace[close]",$text);
}
foreach($sTagArray as $tagName=>$replace){
$text= preg_replace("|\[$tagName\]|Ui","$replace[tag]",$text);
}
$text = str_replace("
- ","
- ",$text);
$text = str_replace("
$text = nl2br($text);
return $text;
}
$getnewsposts = "SELECT topic_poster,topic_time,topic_first_post_id FROM phpbb_topics WHERE forum_id='7'ORDER BY `topic_id` DESC" ;
$postsquery = mysql_query($getnewsposts) or die(mysql_error());
while ($posts = mysql_fetch_array($postsquery)) {
$topic_id = $posts['topic_first_post_id'];
$topic_poster = $posts['topic_poster'];
$topic_time = date("m/d/y g:i a",$posts['topic_time']);
$getposter = mysql_query("SELECT username FROM phpbb_users WHERE user_id='$topic_poster'");
$poster = mysql_result($getposter, 0);
$getposttext = "SELECT bbcode_uid,post_subject,post_text FROM phpbb_posts_text WHERE post_id='$topic_id'";
$postquery = mysql_query($getposttext) or die(mysql_error());
$post = mysql_fetch_array($postquery) or die(mysql_error());
$post_subject = $post['post_subject'];
$bbcode_uid = $post['bbcode_uid'];
$text = $post['post_text'];
$text = str_replace(":".$bbcode_uid,"",$text);
$text = str_replace(":u","",$text);
$text = parseBBCode($text);
?>
= $post_subject; ?>
= $text; ?>
Written by: = $poster; ?>
}
?>