Topic: I have a problem with news

Hi!

I have just installed punBB and i really like it, thanks. But i have one problem so far, i have done a miniportal and i use a forum called pun_news to post news in a box on the first page. But i want every new post to exist in its own box but instead every news i post comes in the same box with only a space between. My page is in Swedish but you can se what i meen at http://www.usland.se

/André

2 (edited by Ludo 2005-06-10 13:38)

Re: I have a problem with news

Modify news.tpl, put only this code in:

<div class="block"><h2><span><news_subject></span></h2>
<div class="box"><div class="inbox"><p><news_message></p>
        <p class="postedby">Posté par <news_poster>, le <news_posted> | <news_comments></p>
</div>
</div>
</div>

Ludo,

Re: I have a problem with news

thats just a feature of the news thing, it will start a new box when its a new day, it puts all news on the same date in the same box, if you want try replacing

function pun_news () {
....
}

with
the code in this post http://punbb.org/forums/viewtopic.php?pid=41647#p41647

Re: I have a problem with news

thanks for fast respons to my post.

The thing is......I do not have a news.tpl? The only thing i did was to follow directions for miniportal. I then made i forum called pun_news and when i post there i get a news flash on my first page. Can you direct me where to do the changes.

/André

Re: I have a problem with news

open the index.php you made using the miniportal guide and theres a big block of code starting

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

and ending

    return $output;
}

replace that with

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, t.num_replies, 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'].'" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a>';
        $newsfooter = '<br /><em>Posted by '.$cur_topic['poster'].' | '.format_time($cur_topic['posted']).' | Comments(<a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.$cur_topic['num_replies'].'</a>)</em>';
        // Group posts by date    
        $thisdate = date('l, d F Y', $cur_topic['posted']);
        if ($saveddate)
        {
            $temp .= "</div></div>";
        }
        $temp .= '<div class="block"><h2><span>'.$newsheading.'</span></h2><div class="box"><div class="inbox">';
        $saveddate = $thisdate;
        $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'] . "<p>";
        $temp .= $newsfooter;
        $temp .= "</p></div>";
        if (isset($output)) {
            $output .= $temp;
        }
        else {
            $output = $temp;
        }
        ++$show_count;
    } // end of while
    $output .= "</div></div>";
    return $output;
}

Re: I have a problem with news

Thanks for your help and thanks for a wounderful forum, pubBB rules.

I have tried several forums and all of them have thousads of functions, to get users to actually use a forum like phpBB there must be a 2 week course :-) punBB have the funktions to use a small and fast forum and with som help from people like Frank i also have a perfect attachment mod.

The function to post news from the same day into the same box is okey, i didnt know this was a function in punBB so i will not modifiy the code but thanks anyway for your help.

//André