BBcode on news from phpbb

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

BBcode on news from phpbb

Post by gaogier »

Hi Guys.

I have code that takes the first post from a topic and shows it as news on a home page. When the news shows it will now show links, ect using BBcode, i am told that i need to make the sure the script is calling the phpBB generate_text_for_display() function to parse it. but i didnt create the code, and no idea where it should go, anyone help?

Code: Select all

<?php
 
//function displayNews($all = 0) {
//global $sitestyle;
    require_once ('../mysql_connect1.php');//connect to db
    if ($all == 0) {   
            $topic_query = "SELECT * FROM `phpbb_topics` WHERE `forum_id`= '63' ORDER BY `topic_time` DESC LIMIT 1"; // do topic query
    }else{
            $topic_query = "SELECT * FROM `phpbb_topics` WHERE `forum_id`= '63' ORDER BY `topic_time` DESC"; // do topic query
    }
        $topic_result = mysql_query ($topic_query);
            while ($topic_row = mysql_fetch_assoc($topic_result)) {
                $tt = $topic_row['topic_time'];
                $topic = $topic_row['topic_id'];
                $poster = $topic_row['topic_poster'];
                $first = $topic_row['topic_first_post_id'];
                $title = $topic_row['topic_title'];
                $topic_replies = $topic_row['topic_replies'];
                $topic_runescape = $topic_row['topic_runescape'];
                $post_query = "SELECT * FROM `phpbb_posts` WHERE  `topic_id` = '$topic' AND `poster_id` = '$poster' AND `post_id` = '$first'"; // do post subject query
                $post_result = mysql_query($post_query);
                while ($post_row = mysql_fetch_assoc($post_result)){
                    $post_id = $post_row['post_id'];
                }
                $use_query = "SELECT `username`, `user_avatar`, `user_email`, `user_rank` FROM `phpbb_users` WHERE `user_id` = '$poster'"; // do user query
                $use_result = mysql_query($use_query);
                while ($use_row = mysql_fetch_assoc($use_result)){
                     $user = $use_row['username'];
                     $user_avatar = $use_row['user_avatar'];
                     $user_email = $use_row['user_email'];
                     $rank = $use_row['user_rank'];                 
                }
                $news_query = "SELECT `post_text` FROM `phpbb_posts` WHERE `post_id`='$post_id'";
                $news_result = mysql_query($news_query);
                while ($news_row = mysql_fetch_assoc($news_result)){
                    $news = $news_row['post_text'];
                }
                $rank_result = mysql_query("SELECT `rank_title` FROM `phpbb_ranks` WHERE `rank_id`='$rank'");
                while($rank_row = mysql_fetch_assoc($rank_result)){
                    $ranks = $rank_row['rank_title'];
                }
                $date = date("D M jS, Y g:i a", $tt);
                if ($topic_replies == 0){
                $reply = '<a href="http://www.runehints.com/phpBB3/posting.php?mode=reply&f=63&t='.$topic.'">Nobody has commented on this piece of news yet. Be the first!</a>';
                $post_new ="";
                }else{
                $reply =  'comments(<a href="http://www.runehints.com/phpBB3/viewtopic.php?t='.$topic.'">'.$topic_replies.'</a>) |';
                $post_new = '<a href="http://www.runehints.com/phpBB3/posting.php?mode=reply&f=63&t='.$topic.'">Post a comment</a>';
                }
                if ($topic_runescape == 1){
                    $news1 = 'This news topic is taken straight from <a href="http://runescape.com">Runescape.com</a><br />_____________________________________________<br /><br />'.$news;
                }else{
                    $news1 = $news;
                }
                // Replace newlines //
                $news2 = str_replace("\n", "\n<br />\n", $news1);
        ?>
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Re: BBcode on news from phpbb

Post by gaogier »

I am still wanting to find out...

anyone know, i am not good with php, not alone adding more code to it...
anto91
Forum Commoner
Posts: 58
Joined: Mon Mar 10, 2008 10:59 am
Location: Sweden

Re: BBcode on news from phpbb

Post by anto91 »

I think its not a code error im sure you can set it up in the admin panel somewere
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Re: BBcode on news from phpbb

Post by gaogier »

the admin panel is home made...

can i still make it add there? i just want bbcode working on the news articals...
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Re: BBcode on news from phpbb

Post by gaogier »

did you mean admin panel of the forums?
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Re: BBcode on news from phpbb

Post by gaogier »

Anyone know how to solve this...?

Can anyone dumb down what they are saying here, has it got anything to do with what i want?

http://www.phpbb.com/community/viewtopi ... &sk=t&sd=a
Post Reply