Topic: Miniportal is grabbing the wrong post's text

I've got Miniportal installed at http://www.mkdsc.com/index.php

http://img296.imageshack.us/img296/7910/mkdscscreen18tg.th.jpg

http://img296.imageshack.us/img296/4369/mkdscscreen20cf.th.jpg

In the first screenshot, look at the first news entry.  That was a reply of a members, not the original thread post.

In the second shot, the same thing happens.

My index.php

<?php
 
define('PUN_ROOT', './');
//define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';
 
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';

function pun_news($fid='', $show=15, $truncate=1)
{
    global $lang_common, $db, $pun_config, $db_prefix;
    $max_subject_length = 30;
    $show_max_topics = 50;
    $fid = intval($fid);
    $order_by = 't.posted';
    $forum_sql = '';
    // Was a forum ID supplied?
    if ( $fid ) $forum_sql = 'f.id='.$fid.' AND ';
    $show = intval($show);
    if ($show < 1 || $show > $show_max_topics)
    $show = 15;
    $saveddate="";
    // Fetch $show topics
    $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
    $show_count = 0;
    if ( !$db->num_rows($result) ) return $output;
    while ( ($show_count < $show) && ($cur_topic = $db->fetch_assoc($result)) ) {
        $temp = '';
        if ($pun_config['o_censoring'] == '1')
            $cur_topic['subject'] = censor_words($cur_topic['subject']);
        if (pun_strlen($cur_topic['subject']) > $max_subject_length)
            $subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
        else
            $subject_truncated = $cur_topic['subject'];
        $newsheading = '<a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a> - <em>Posted by '.$cur_topic['poster'].' at '.date('h:i A', $cur_topic['posted']).'</em><br>';
        // Group posts by date    
        $thisdate = date('l, d F Y', $cur_topic['posted']);
        if ($thisdate != $saveddate) 
 
        {
            if ($saveddate)
            {
                $temp .= "</div></div>";
            }
            $temp .= '<div class="block"><h2><span>'.$thisdate.'</span></h2><div class="box"><div class="inbox"><p>';
            $saveddate = $thisdate;
        }
        else {
            $temp .= '<div class="inbox"><p>';
        }
        $temp .= $newsheading.'</p><p>';
        $id = $cur_topic['id'];
        $msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
            if ( !$db->num_rows($msg) ) continue;
        $cur_post = $db->fetch_assoc($msg);
        // Display first paragraph only (comment out next four lines to turn off)
        if ($truncate == 1)
        {
        $paragraph = preg_split("/s*n+/", $cur_post['message']);
            if (isset($paragraph[1])) {
                $cur_post['message'] = $paragraph[0] . "...";
            }
        }
        $cur_post['message'] = parse_message($cur_post['message'], 0);
        $temp .= $cur_post['message'];
        $temp .= "</p></div>";
        if (isset($output)) {
            $output .= $temp;
        }
        else {
            $output = $temp;
        }
        ++$show_count;
    } // end of while
    $output .= "</div></div>";
    return $output;
}

?>
        <div class="block">
            <h2><span>Welcome</span></h2>
            <div class="box">
                <div class="inbox">
                    <p>
                    Welcome to Mario Kart: DS Central.  To visit the Forums, please select "Forum" from the menu to the left, or the top navigation bar.
                    </p>
                </div>
            </div>
        </div>
<?php
echo pun_news(12, 7, 0);
 
require PUN_ROOT.'footer.php';

I haven't modified the function's code, so I don't know what could be causing this sad

Other than this problem, it seems to be working fine, great work smile

2 (edited by Dr.Jeckyl 2006-01-14 09:57)

Re: Miniportal is grabbing the wrong post's text

if you want the news to come from the "Announcements" forum then you need to tell the mini portal index.php that is the forum it needs to get it from. ie:

function pun_news($fid='12', $show=15, $truncate=1)

the $fid='12' is the forum id it draws the news/announcements from which i'm assuming is this forum: http://www.mkdsc.com/viewforum.php?id=12  <-----  see the 12.

http://www.punres.org/doku.php?id=tutorials:miniportal

all about the mini portal. i hope this helps.

~James
FluxBB - Less is more

3 (edited by StevenBullen 2006-01-14 10:31)

Re: Miniportal is grabbing the wrong post's text

I had a problem very simliar to this as well....

My fix was this...

find...

$msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

change to...

$msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' ORDER BY posted ASC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

once again... if any PunBB admin or mods think this could cause any problems please let me know...

Extra Note: This fix works fine for my forum and members. smile

Re: Miniportal is grabbing the wrong post's text

@Dr. jeckyl...

What are you going on about? He has printed the code... and shows the

echo pun_news(12, 7, 0);

Whats your point Jeckyl?

Re: Miniportal is grabbing the wrong post's text

Dr.Jeckyl wrote:

if you want the news to come from the "Announcements" forum then you need to tell the mini portal index.php that is the forum it needs to get it from. ie:

function pun_news($fid='12', $show=15, $truncate=1)

the $fid='12' is the forum id it draws the news/announcements from which i'm assuming is this forum: http://www.mkdsc.com/viewforum.php?id=12  <-----  see the 12.

http://www.punres.org/doku.php?id=tutorials:miniportal

all about the mini portal. i hope this helps.

Wrong. You do not edit that line, you edit the one lower down.

StevenBullen: Yeh that fixes it I think, its posted somewhere in the miniportal thread.

Re: Miniportal is grabbing the wrong post's text

Thanks Steven, that fixed it smile

7

Re: Miniportal is grabbing the wrong post's text

Thanks Steven!  I'd given up trying to figure this out, but here it is.

8

Re: Miniportal is grabbing the wrong post's text

StevenBullen wrote:

I had a problem very simliar to this as well....

My fix was this...

find...

$msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

change to...

$msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' ORDER BY posted ASC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

once again... if any PunBB admin or mods think this could cause any problems please let me know...

Extra Note: This fix works fine for my forum and members. smile

Here we go, I have been looking for this.  My only question is which file is this in to modify?  I don't recognize it.