1 (edited by jochem 2004-02-15 11:09)

Topic: show post on mainsite

i didn't realy know where to post this, so decided to post it in the PunBB discussions.

What i would like to do is, having a board on the forums for administratos and moderators where they can post messages that will show up on the mainpage of the site as "news". That way it would be very easy to update the news section of the site.

I already have it so that the topics in a certain board are shown on the mainpage. But all those B, U, I, QUOTE etc codes are not yet changed to the html codes etc..
I believe the forums use the parser.php file, am i correct? Is there an easy way to use that same file on the mainpage to change those B, U etc codes to html?

You can take a look here: http://www.dutcholsentwins.com
scroll down to all the messages, it's below the actual layout, so it's kind of messed up now wink
But you'll see what i mean. One of the messages has the

[quote]

code in it.

Thank you,
Jochem.

Re: show post on mainsite

Yes, just include parser.php and then call

$message = parse_message($message, $smilies);

Where $smilies is one or zero depending on whether you want to convert smilies to images or not.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3 (edited by jochem 2004-02-15 13:02)

Re: show post on mainsite

mmm, i get this error:

Fatal error: Call to undefined function: parse_message() in /home/dolsentw/public_html/index.php on line 193

i have this code right now:

<?

$sql = "SELECT *
        FROM ".$db_prefix."posts as a, ".$db_prefix."topics as b
        WHERE b.forum_id = ".$news_id."
          AND a.topic_id = b.id";
$result = mysql_query($sql) or die ("Error2_main: ".mysql_error()."<p>".$sql);

while ($row = mysql_fetch_array($result)) {
 $message = $row['message'];
 $smilies = 1;
 $message = parse_message($message, $smilies);
}

?>

edit:
changed the include from
include ("http://www.dutcholsentwins.com/forum/nl … parser.php");
to
include ("forum/nl/include/parser.php")';

now i get this error:
Fatal error: Call to undefined function: pun_htmlspecialchars() in /home/dolsentw/public_html/forum/nl/include/parser.php on line 274

Re: show post on mainsite

Ah, of course. Before you include parser.php, you have to include functions.php as well.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: show post on mainsite

www.dutcholsentwins.com (scroll down)
the quotes and urls and the B, U etc codes are still not parsed sad

Re: show post on mainsite

Well, they should if you run the message through parse_message before you output it. You must have made a mistake somewhere in your code.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: show post on mainsite

the message goes through parse_message before i do the output, see my code:

<?

$sql = "SELECT *
        FROM ".$db_prefix."posts as a, ".$db_prefix."topics as b
        WHERE b.forum_id = ".$news_id."
          AND a.topic_id = b.id";
$result = mysql_query($sql) or die ("Error2_main: ".mysql_error()."<p>".$sql);
$smilies = 1;

while ($row = mysql_fetch_array($result)) {
 $message = $row['message'];
 $message = parse_message($message, $smilies);
 print "<p>bericht: ".$message;
}

?>

mmmmmm....

Re: show post on mainsite

well, i made a test page now, so it's no longer on my site:
http://www.dutcholsentwins.com/test.php
as you see it realy does not work correctly.. the linebreaks work though.. :s

Re: show post on mainsite

I'm sorry, it's me again :) Try this:

$pun_config['o_censoring'] = '1';
$pun_config['o_make_links'] = '1';
$pun_config['o_smilies'] = '1';
$pun_config['p_message_bbcode'] = '1';
$pun_config['p_message_img_tag'] = '1';

Then, run parse_message().

"Programming is like sex: one mistake and you have to support it for the rest of your life."

10

Re: show post on mainsite

yes smile
thank you!

though i have to remove this line:
$pun_config['o_censoring'] = '1';

otherwise i get this error:
Fatal error: Call to a member function on a non-object in /home/dolsentw/public_html/forum/nl/include/functions.php on line 274

Re: show post on mainsite

Hmm, ok. Do you want censoring on the front page? If you do, I can probably fix that error.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

12

Re: show post on mainsite

I don't think i'll need it. It are only the administrators and moderators who can post in the boards of which the posts show on the mainpage. If they say something that would need to be censored i will just slap them smile

Re: show post on mainsite

excuse me for being such a moron, but I don't get the above code to work, even though I defined $news_id, is there something else that needs to be done with that code?

Niklas