PunBB Resource

Your ultimate PunBB resource!

Keywords:

    (Extended)

You are not logged in.

#1 2015-01-01 18:45:31

OhioGeek
New member
Registered: 2015-01-01
Posts: 2

BBCode Outside of Forums

I am using the punbb version downloaded from here and I have neutral's modern bbcode loaded. I also use the following sscript to pull posts from a topic called "news" and have it displayed on the front page of my site:

Code:

<?php

/**
Punbb News Script
Written by: Jesse Spillane (http://www.jessespillane.com)
*/

$news_forum_id = 6;
$news_forum_id2 = 7;
$limit = 7;
$forum_path = './forums/';

define('PUN_ROOT', $forum_path);

define('PUN_TURN_OFF_MAINT', 1);
define('PUN_QUIET_VISIT', 1);

require PUN_ROOT.'include/parser.php';
$result = $db->query('select id, subject, num_replies, posted from '.$db->prefix.'topics WHERE forum_id='.$news_forum_id.' OR forum_id='.$news_forum_id2.' ORDER BY -posted LIMIT '.$limit.';')or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
while ($row = $db->fetch_assoc($result))
{
    $id = $row['id'];
    $subject = $row['subject'];
    $num_replies = $row['num_replies'];
    $posted = date("F j, Y, g:i a", $row['posted']);

    $result2 = $db->query('select message, poster from '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY id LIMIT 1 ')or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
    
    $post = $db->fetch_assoc($result2);
    $message = parse_message($post['message'], 1);
    $poster = $post['poster'];

?>
<br>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" class="main_content" height="75">
    <tr>
      <td width="100%" background="images/navbar_gradiant.png" height="19" colspan="2">
      <p style="text-indent: 3; margin: 2 3"><b><?php echo '<a href='.$forum_path.'viewtopic.php?id='.$id.'">
      <font face="Verdana" size="2" color="#FF0000">'.$subject.'</a>'; ?></font></b></td>
    </tr>
    <tr>
      <td width="100%" height="37" background="images/main_cont_gradiant.png" colspan="2" valign="top">
      <div align="center">
        <center>
        <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="99%">
          <tr>
            <td width="100%">
            <p style="margin-top: 4; margin-bottom: 4">
            <font face="Verdana" size="2"><?php echo $message;?></font></td>
          </tr>
        </table>
        </center>
      </div>
      </td>
    </tr>
    <tr>
      <td width="82%" height="19" background="images/navbar_gradiant.png">
      <p style="margin: 2 3">&nbsp;</td>
      <td width="18%" height="19" background="images/navbar_gradiant.png">
      <p align="right" style="margin: 2 3"><i>
      <font face="Verdana" size="2" color="#FF0000"><?php
    echo '<a style="text-decoration: none" href='.$forum_path.'viewtopic.php?id='.$id.'">
   '.$num_replies.' Comment(s)</a>';
   ?></font></i></td>
    </tr>
  </table>



<?php

}

?>

But the problem is any BBcode I use in thread as far as text size or centering doesnt transfer to the topic posted outside the forums on the main page of my site. Does anyone know how I can fix it

Thanks smile

Offline

 

#2 2015-01-08 14:50:13

Koos
Administrator
Registered: 2007-01-14
Posts: 525
Website

Re: BBCode Outside of Forums

Hi, it looks like the script you posted only displays the first post of topics in a specified forum, and not all posts from a specific topic.  You must also include the line:

Code:

require PUN_ROOT.'include/common.php';

in the script.

I tested the script, and the text sizes, colours etc. did transfer, except text alignment, since that is specified in the imports/imports/base.css file.

If you want alignment to also display correctly on your home page, you can include the following in your home page's style sheet (taken from the modern bbcode modification made to imports/imports/base.css):

Code:

<style>
/****************************************************************/
/* MOD MODERN BBCODE: ADDITIONAL BBCODE INDICATORS */
/****************************************************************/

p.center {
    text-align: center;
}

p.right {
    text-align: right;
}

span.bbs {
    text-decoration: line-through;    
}

code {
    font-family: "Courier New";
    font-size: 110%;
}

div.postmsg ol, div.postmsg ul {
    padding: 5px;
}

div.postmsg li {
    margin-left: 30px;
    padding: 2px;
}

div.postmsg ol li {
    list-style-type: decimal;
}

div.postmsg ul li {
    list-style-type: square;
}
</style>

Offline

 

#3 2015-01-09 22:00:16

OhioGeek
New member
Registered: 2015-01-01
Posts: 2

Re: BBCode Outside of Forums

Do I just add that to my home page's css file or the one in the forum

Offline

 

#4 2015-01-21 20:28:17

Koos
Administrator
Registered: 2007-01-14
Posts: 525
Website

Re: BBCode Outside of Forums

Yes, you must add it to your home page's style sheet.

Offline

 

Board footer

Based on PunBB
© Copyright 2002–2005 Rickard Andersson

© Copyright 2004–2006 Kristoffer Jansson

User contributed files are property of their respective owners.